package cn.firstsoft.modules.workflow.web;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.acegisecurity.providers.encoding.Md5PasswordEncoder;
import org.acegisecurity.providers.encoding.PasswordEncoder;
import org.apache.commons.lang.StringUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
import org.springside.core.commons.BaseManageController;
import org.springside.core.commons.BusinessException;
import org.springside.core.commons.PageSortModel;
import org.springside.core.commons.QueryVO;
import org.springside.core.utils.DateUtil;
import org.springside.core.utils.FileUtil;
import org.springside.core.utils.StrUtils;
import org.springside.modules.security.domain.Dept;
import org.springside.modules.security.domain.Permission;
import org.springside.modules.security.domain.Role;
import org.springside.modules.security.domain.SystemDictionary;
import org.springside.modules.security.domain.SystemHierarchy;
import org.springside.modules.security.domain.SystemPositionmember;
import org.springside.modules.security.domain.User;
import org.springside.modules.security.domain.UserSession;
import org.springside.modules.security.service.logic.DeptManager;
import org.springside.modules.security.service.logic.DictManager;
import org.springside.modules.security.service.logic.SystemDictionaryManager;
import org.springside.modules.security.service.logic.SystemPositionhierarchyManager;
import org.springside.modules.security.service.logic.SystemPositionmemberManager;
import org.springside.modules.security.service.logic.SystemWorkhourManager;
import org.springside.modules.security.service.logic.UserManager;

import cn.firstsoft.firstframe.plugins.upload.web.Upload;
import cn.firstsoft.firstframe.util.AuthUtils;
import cn.firstsoft.firstframe.util.ObjectComparator;
import cn.firstsoft.firstframe.util.ReflectUtil;
import cn.firstsoft.firstframe.util.StorageUtil;
import cn.firstsoft.firstframe.util.UrlUtil;
import cn.firstsoft.modules.docex.domain.DocexFile;
import cn.firstsoft.modules.docex.domain.DocexFileattach;
import cn.firstsoft.modules.docex.domain.DocexFiledetail;
import cn.firstsoft.modules.docex.service.logic.DocexFileManager;
import cn.firstsoft.modules.docex.service.logic.DocexFileattachManager;
import cn.firstsoft.modules.docex.service.logic.DocexFiledetailManager;
import cn.firstsoft.modules.message.domain.Messages;
import cn.firstsoft.modules.message.domain.Title;
import cn.firstsoft.modules.message.service.logic.MessagesManager;
import cn.firstsoft.modules.pl.domain.PlBaoxiao;
import cn.firstsoft.modules.pl.domain.PlBaoxiaoMx;
import cn.firstsoft.modules.pl.domain.PlDicts;
import cn.firstsoft.modules.pl.domain.PlFentan;
import cn.firstsoft.modules.pl.domain.PlFentanBase;
import cn.firstsoft.modules.pl.domain.PlFentanMx;
import cn.firstsoft.modules.pl.domain.PlHuizong;
import cn.firstsoft.modules.pl.domain.PlKemu;
import cn.firstsoft.modules.pl.service.logic.PlBaoxiaoManager;
import cn.firstsoft.modules.pl.service.logic.PlBaoxiaoMxManager;
import cn.firstsoft.modules.pl.service.logic.PlDictsManager;
import cn.firstsoft.modules.pl.service.logic.PlFentanBaseManager;
import cn.firstsoft.modules.pl.service.logic.PlFentanManager;
import cn.firstsoft.modules.pl.service.logic.PlFentanMxManager;
import cn.firstsoft.modules.pl.service.logic.PlHuizongManager;
import cn.firstsoft.modules.pl.service.logic.PlKemuManager;
import cn.firstsoft.modules.workflow.WorkFlowUtil;
import cn.firstsoft.modules.workflow.domain.Workflow;
import cn.firstsoft.modules.workflow.domain.WorkflowDicts;
import cn.firstsoft.modules.workflow.domain.WorkflowFile;
import cn.firstsoft.modules.workflow.domain.WorkflowFilePrintInfo;
import cn.firstsoft.modules.workflow.domain.WorkflowFileattach;
import cn.firstsoft.modules.workflow.domain.WorkflowFileinbox;
import cn.firstsoft.modules.workflow.domain.WorkflowFileno;
import cn.firstsoft.modules.workflow.domain.WorkflowFileopinion;
import cn.firstsoft.modules.workflow.domain.WorkflowFileprocess;
import cn.firstsoft.modules.workflow.domain.WorkflowFlowfield;
import cn.firstsoft.modules.workflow.domain.WorkflowFlowtype;
import cn.firstsoft.modules.workflow.domain.WorkflowOperation;
import cn.firstsoft.modules.workflow.domain.WorkflowSearch;
import cn.firstsoft.modules.workflow.domain.WorkflowSearchField;
import cn.firstsoft.modules.workflow.domain.WorkflowShortopinion;
import cn.firstsoft.modules.workflow.domain.WorkflowSignature;
import cn.firstsoft.modules.workflow.domain.WorkflowStep;
import cn.firstsoft.modules.workflow.domain.WorkflowWebsign;
import cn.firstsoft.modules.workflow.domain.WorkflowWordtemplate;
import cn.firstsoft.modules.workflow.service.logic.SubwordItemManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowConvertManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowDictsManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFileManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFilePrintInfoManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFileattachManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFiledetailManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFilelockManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFlowRightManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFlowfieldManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowFlowtypeManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowIntegrationManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowKnowledgeManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowOperationManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowSearchFieldManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowSearchManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowShortopinionManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowSignatureManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowSpecManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowStepManager;
import cn.firstsoft.modules.workflow.service.logic.WorkflowWebsignManager;

import com.goldhat.modules.workflow.domain.WorkflowFileChange;
import com.goldhat.modules.workflow.service.logic.WorkflowFileChangeManager;

public class WorkflowFileinboxManagerController
  extends BaseManageController
{
  private WorkflowKnowledgeManager workflowKnowledgeManager;
  private WorkflowSearchManager workflowSearchManager;
  private WorkflowFlowRightManager workflowFlowRightManager;
  private WorkflowSearchFieldManager workflowSearchFieldManager;
  private DictManager dictManager;
  private MessagesManager messagesManager;
  private WorkflowConvertManager workflowConvertManager;
  private cn.firstsoft.modules.workflow.service.logic.WorkflowFileinboxManager workflowFileinboxManager;
  private cn.firstsoft.modules.expense.service.logic.WorkflowFileinboxManager workflowFileinboxManager1;
  private SystemDictionaryManager systemDictionaryManager;
  private WorkflowFlowtypeManager workflowFlowtypeManager;
  private WorkflowFlowfieldManager workflowFlowfieldManager;
  private WorkflowFileManager workflowFileManager;
  private WorkflowStepManager workflowStepManager;
  private WorkflowManager workflowManager;
  private WorkflowFileattachManager workflowFileattachManager;
  private WorkflowSignatureManager workflowSignatureManager;
  private SubwordItemManager subwordItemManager;
  private WorkflowShortopinionManager workflowShortopinionManager;
  private DeptManager deptManager;
  private UserManager userManager;
  private DocexFileManager docexFileManager;
  private DocexFileattachManager docexFileattachManager;
  private DocexFiledetailManager docexFiledetailManager;
  private WorkflowSpecManager workflowSpecManager;
  private SystemPositionmemberManager systemPositionmemberManager;
  private WorkflowFilelockManager workflowFilelockManager;
  private WorkflowDictsManager workflowDictsManager;
  private PlBaoxiaoManager plBaoxiaoManager;
  private PlDictsManager plDictsManager;
  private PlBaoxiaoMxManager plBaoxiaoMxManager;
  private PlFentanManager plFentanManager;
  private PlFentanBaseManager plFentanBaseManager;
  private PlKemuManager plKemuManager;
  private JdbcTemplate jdbcTemplate;
  private PlFentanMxManager plFentanMxManager;
  private PlHuizongManager plHuizongManager;
  private WorkflowFilePrintInfoManager workflowFilePrintInfoManager;
  private WorkflowIntegrationManager workflowIntegrationManager;
  private WorkflowOperationManager workflowOperationManager;
  private SystemWorkhourManager systemWorkhourManager;
  private SystemPositionhierarchyManager systemPositionhierarchyManager;
  private WorkflowFiledetailManager workflowFiledetailManager;
  private WorkflowWebsignManager workflowWebsignManager;
  private static final String DRAFT_LIST = "/modules/workflow/workflowFileinbox_draft.jsp";
  private static final String SENT_LIST = "/modules/workflow/workflowFileinbox_sent.jsp";
  private static final String MEMBER_VIEW = "/modules/workflow/workflowFileinbox_member.jsp";
  private static final String PROCESS_VIEW = "/modules/workflow/workflowFileinbox_process.jsp";
  private static final String HURRY_VIEW = "/modules/workflow/workflowFileinbox_hurry.jsp";
  private static final String HURRYPROCESS_VIEW = "redirect:/modules/workflow/workflowFileinbox.do?method=process&openwin=true&fileId=";
  private static final String MONITOR_VIEW = "/modules/workflow/workflowFileinbox_monitor.jsp";
  private static final String MONITORPROCESS_VIEW = "redirect:/modules/workflow/workflowFileinbox.do?method=process&openwin=true&fileId=";
  private static final String STEP_VIEW = "/modules/workflow/workflowFileinbox_step.jsp";
  private static final String FINISH_VIEW = "/modules/workflow/workflowFileinbox_finish.jsp";
  private static final String TRANSFER_VIEW = "/modules/workflow/workflowFileinbox_transfer.jsp";
  private static final String DOCEX_VIEW = "/modules/workflow/workflowFileinbox_docex.jsp";
  private static final String DOCEXFINISH_VIEW = "/modules/workflow/workflowFileinbox_docexfinish.jsp";
  private static final String INBOX_VIEW = "redirect:/modules/workflow/workflowFileinbox.do?ec_s_startdate=desc";
  private static final String SENT_VIEW = "redirect:/modules/workflow/workflowFileinbox.do?method=sent&id=";
  private static final String EDIT_VIEW = "redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=";
  private static final String SHOW_VIEW = "/modules/workflow/workflowFileinbox.do?method=show&id=";
  private static final String ONLINE_VIEW = "redirect:/modules/workflow/workflowFileattach.do?method=online";
  private static final String FILENO_VIEW = "/modules/workflow/workflowFileinbox_fileno.jsp";
  private static final String SUBWORD_VIEW = "/modules/workflow/workflowFileinbox_subword.jsp";
  private static final String SIGNATURE_VIEW = "/modules/workflow/workflowFileinbox_signature.jsp";
  private static final String OPINION_VIEW = "/modules/workflow/workflowFileinbox_opinion.jsp";
  private static final String SPECIAL_VIEW = "/modules/workflow/workflowFileinbox_special.jsp";
  private static final String GETBACKSPECIAL_VIEW = "/modules/workflow/workflowFileinbox.do?method=getSpecial";
  private static final String newView = "/modules/workflow/workflowFileinbox_new.jsp";
  private static final String DICTS_VIEW = "/modules/workflow/workflowFileinbox_dicts.jsp";
  private static final String STEP_USER_VIEW = "/modules/workflow/workflowFileinbox_step_user.jsp";
  private static final String TREEDICTS_VIEW = "/modules/workflow/workflowFileinbox_treedicts.jsp";
  private static final String BATCHLIST_VIEW = "/modules/workflow/workflowFileinbox_batchlist.jsp";
  private static final String SCAN_VIEW = "/modules/workflow/workflowFileinbox_scan.jsp";
  
  public void setWorkflowFlowRightManager(WorkflowFlowRightManager workflowFlowRightManager)
  {
    this.workflowFlowRightManager = workflowFlowRightManager;
  }
  
  public void setDictManager(DictManager dictManager)
  {
    this.dictManager = dictManager;
  }
  
  public void setMessagesManager(MessagesManager messagesManager)
  {
    this.messagesManager = messagesManager;
  }
  
  public void setWorkflowConvertManager(WorkflowConvertManager workflowConvertManager)
  {
    this.workflowConvertManager = workflowConvertManager;
  }
  
  public void setWorkflowFileinboxManager(cn.firstsoft.modules.workflow.service.logic.WorkflowFileinboxManager workflowFileinboxManager)
  {
    this.workflowFileinboxManager = workflowFileinboxManager;
  }
  
  public void setWorkflowFileinboxManager1(cn.firstsoft.modules.expense.service.logic.WorkflowFileinboxManager workflowFileinboxManager1)
  {
    this.workflowFileinboxManager1 = workflowFileinboxManager1;
  }
  
  public void setSystemDictionaryManager(SystemDictionaryManager systemDictionaryManager)
  {
    this.systemDictionaryManager = systemDictionaryManager;
  }
  
  public void setWorkflowFlowtypeManager(WorkflowFlowtypeManager workflowFlowtypeManager)
  {
    this.workflowFlowtypeManager = workflowFlowtypeManager;
  }
  
  public void setWorkflowFlowfieldManager(WorkflowFlowfieldManager workflowFlowfieldManager)
  {
    this.workflowFlowfieldManager = workflowFlowfieldManager;
  }
  
  public void setWorkflowFileManager(WorkflowFileManager workflowFileManager)
  {
    this.workflowFileManager = workflowFileManager;
  }
  
  public void setWorkflowStepManager(WorkflowStepManager workflowStepManager)
  {
    this.workflowStepManager = workflowStepManager;
  }
  
  public void setWorkflowManager(WorkflowManager workflowManager)
  {
    this.workflowManager = workflowManager;
  }
  
  public void setWorkflowFileattachManager(WorkflowFileattachManager workflowFileattachManager)
  {
    this.workflowFileattachManager = workflowFileattachManager;
  }
  
  public void setWorkflowSignatureManager(WorkflowSignatureManager workflowSignatureManager)
  {
    this.workflowSignatureManager = workflowSignatureManager;
  }
  
  public void setSubwordItemManager(SubwordItemManager subwordItemManager)
  {
    this.subwordItemManager = subwordItemManager;
  }
  
  public void setWorkflowShortopinionManager(WorkflowShortopinionManager workflowShortopinionManager)
  {
    this.workflowShortopinionManager = workflowShortopinionManager;
  }
  
  public void setDeptManager(DeptManager deptManager)
  {
    this.deptManager = deptManager;
  }
  
  public void setUserManager(UserManager userManager)
  {
    this.userManager = userManager;
  }
  
  public void setDocexFileManager(DocexFileManager docexFileManager)
  {
    this.docexFileManager = docexFileManager;
  }
  
  public void setDocexFileattachManager(DocexFileattachManager docexFileattachManager)
  {
    this.docexFileattachManager = docexFileattachManager;
  }
  
  public void setDocexFiledetailManager(DocexFiledetailManager docexFiledetailManager)
  {
    this.docexFiledetailManager = docexFiledetailManager;
  }
  
  public WorkflowSpecManager getWorkflowSpecManager()
  {
    return this.workflowSpecManager;
  }
  
  public void setWorkflowSpecManager(WorkflowSpecManager workflowSpecManager)
  {
    this.workflowSpecManager = workflowSpecManager;
  }
  
  public void setSystemPositionmemberManager(SystemPositionmemberManager systemPositionmemberManager)
  {
    this.systemPositionmemberManager = systemPositionmemberManager;
  }
  
  public void setWorkflowFilelockManager(WorkflowFilelockManager workflowFilelockManager)
  {
    this.workflowFilelockManager = workflowFilelockManager;
  }
  
  public void setWorkflowDictsManager(WorkflowDictsManager workflowDictsManager)
  {
    this.workflowDictsManager = workflowDictsManager;
  }
  
  public void setPlBaoxiaoManager(PlBaoxiaoManager plBaoxiaoManager)
  {
    this.plBaoxiaoManager = plBaoxiaoManager;
  }
  
  public void setPlDictsManager(PlDictsManager plDictsManager)
  {
    this.plDictsManager = plDictsManager;
  }
  
  public void setPlBaoxiaoMxManager(PlBaoxiaoMxManager plBaoxiaoMxManager)
  {
    this.plBaoxiaoMxManager = plBaoxiaoMxManager;
  }
  
  public void setPlFentanManager(PlFentanManager plFentanManager)
  {
    this.plFentanManager = plFentanManager;
  }
  
  public void setPlFentanBaseManager(PlFentanBaseManager plFentanBaseManager)
  {
    this.plFentanBaseManager = plFentanBaseManager;
  }
  
  public void setPlKemuManager(PlKemuManager plKemuManager)
  {
    this.plKemuManager = plKemuManager;
  }
  
  public void setJdbcTemplate(JdbcTemplate jdbcTemplate)
  {
    this.jdbcTemplate = jdbcTemplate;
  }
  
  public void setPlFentanMxManager(PlFentanMxManager plFentanMxManager)
  {
    this.plFentanMxManager = plFentanMxManager;
  }
  
  public void setPlHuizongManager(PlHuizongManager plHuizongManager)
  {
    this.plHuizongManager = plHuizongManager;
  }
  
  public void setWorkflowFilePrintInfoManager(WorkflowFilePrintInfoManager workflowFilePrintInfoManager)
  {
    this.workflowFilePrintInfoManager = workflowFilePrintInfoManager;
  }
  
  public void setWorkflowIntegrationManager(WorkflowIntegrationManager workflowIntegrationManager)
  {
    this.workflowIntegrationManager = workflowIntegrationManager;
  }
  
  public void setWorkflowOperationManager(WorkflowOperationManager workflowOperationManager)
  {
    this.workflowOperationManager = workflowOperationManager;
  }
  
  public void setSystemWorkhourManager(SystemWorkhourManager systemWorkhourManager)
  {
    this.systemWorkhourManager = systemWorkhourManager;
  }
  
  public void setSystemPositionhierarchyManager(SystemPositionhierarchyManager systemPositionhierarchyManager)
  {
    this.systemPositionhierarchyManager = systemPositionhierarchyManager;
  }
  
  public void setWorkflowFiledetailManager(WorkflowFiledetailManager workflowFiledetailManager)
  {
    this.workflowFiledetailManager = workflowFiledetailManager;
  }
  
  public void setWorkflowWebsignManager(WorkflowWebsignManager workflowWebsignManager)
  {
    this.workflowWebsignManager = workflowWebsignManager;
  }
  
  private String documentDir = "";
  private static final String EditView_M = "/modules/workflow/workflowFileinbox_edit_mulit.jsp";
  private static final String SEARCH_EDIT = "/modules/workflow/workflow_search_edit.jsp";
  
  public WorkflowFileinboxManagerController()
  {
    this.listView = "/modules/workflow/workflowFileinbox_list.jsp";
    this.editView = "/modules/workflow/workflowFileinbox_edit.jsp";
    this.showView = "/modules/workflow/workflowFileinbox_show.jsp";
    this.successView = "redirect:/modules/workflow/workflowFileinbox.do";
  }
  
  protected void onList(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    UserSession user = getUserSession(request);
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    String searchId = request.getParameter("searchId");
    if ((StringUtils.isNotBlank(searchId)) && (!"null".equals(searchId)))
    {
      WorkflowSearch workflowSearch = this.workflowSearchManager.getWorkflowSearch(Integer.valueOf(searchId));
      String search = request.getParameter("search");
      if (StringUtils.isNotBlank(search))
      {
        map = workflowSearch.getSearchMap();
        mav.setViewName(UrlUtil.getUrlParams(this.listView, map, "search_"));
      }
      else if (this.workflowSearchManager.verifyWorkflowSearch(workflowSearch, map))
      {
        String viewName = mav.getViewName();
        if (viewName.indexOf("?") == -1) {
          viewName = viewName + "?&searchId=";
        }
        mav.setViewName(viewName);
      }
    }
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    String classify = (String)map.get("classify");
    
    String messages = request.getParameter("messages");
    if ((StringUtils.isNotBlank(messages)) || (StringUtils.isEmpty(classify))) {
      classify = org.springside.core.Constants.CLASSIFY_BACKLOG;
    }
    if (StringUtils.isNotBlank(request.getParameter("flowIds")))
    {
      map.remove("workflowXXname_s_like");
      map.put("workflowXXid_i_eq", request.getParameter("flowIds"));
    }
    if (org.springside.core.Constants.CLASSIFY_BACKLOG.equals(classify)) {
      backlog(request, mav, map);
    } else if (org.springside.core.Constants.CLASSIFY_POSTPONE.equals(classify)) {
      postpone(request, mav, map);
    }
    mav.addObject("workflowSearchs", this.workflowSearchManager.getWorkflowSearchList(user.getId(), org.springside.core.Constants.SEARCH_TYPE_BACKLOG));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
    
    mav.addObject("workflow_batch", Boolean.valueOf(AuthUtils.isAuthorized("AUTH_MODULES_WORKFLOW_BATCH")));
  }
  
  public ModelAndView showBatchList(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    mav.setViewName("/modules/workflow/workflowFileinbox_batchlist.jsp");
    UserSession user = getUserSession(request);
    if (!AuthUtils.isAuthorized("AUTH_MODULES_WORKFLOW_BATCH")) {
      createPermException(request, "协同审批->批量审批", null);
    }
    Map signmap = new HashMap();
    signmap.put("userId_i_eq", String.valueOf(user.getId()));
    signmap.put("status_i_eq", "1");
    Map<String, String> orderFilter = new HashMap();
    orderFilter.put("id", "asc");
    orderFilter.put("defaultsign", "desc");
    List<WorkflowSignature> workflowSignatures = this.workflowSignatureManager.findWorkflowSignature(signmap, orderFilter);
    


    Map map = new HashMap();
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_in", "1,2");
    String inboxSort = org.springside.core.Constants.WORKFLOW_INBOX_SORT;
    if ((!"asc".equals(inboxSort)) && (!"desc".equals(inboxSort))) {
      inboxSort = "desc";
    }
    request.removeAttribute("ec_s_startdate");
    Map orderMap = new LinkedHashMap();
    orderMap.put("startdate", inboxSort);
    List workflowFileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(map, orderMap);
    List workflowFileinboxs = new Vector();
    for (int i = 0; i < workflowFileinboxList.size(); i++)
    {
      WorkflowFileinbox workflowFileinbox = (WorkflowFileinbox)workflowFileinboxList.get(i);
      int canCheckin = this.workflowFileinboxManager.getCanbatchCheckin(workflowFileinbox, workflowSignatures);
      if (canCheckin == 1) {
        workflowFileinboxs.add(workflowFileinbox);
      }
    }
    mav.addObject("workflowFileinboxs", workflowFileinboxs);
    
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    
    mav.addObject("workflow_batch_sign", Boolean.valueOf(AuthUtils.isAuthorized("AUTH_MODULES_WORKFLOW_BATCH")));
    return mav;
  }
  
  public ModelAndView signSent(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    String[] ids = request.getParameterValues("itemlist");
    String batchid = "";
    for (int i = 0; i < ids.length; i++) {
      batchid = batchid + ids[i] + ",";
    }
    UserSession session = getUserSession(request);
    
    Map signmap = new HashMap();
    signmap.put("userId_i_eq", String.valueOf(session.getId()));
    signmap.put("status_i_eq", "1");
    Map<String, String> orderFilter = new HashMap();
    orderFilter.put("id", "asc");
    orderFilter.put("defaultsign", "desc");
    List<WorkflowSignature> workflowSignatures = this.workflowSignatureManager.findWorkflowSignature(signmap, orderFilter);
    

    Map filter = new HashMap();
    filter.put("id_i_in", batchid);
    List<WorkflowFileinbox> workflowFileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(filter);
    for (int i = 0; i < workflowFileinboxList.size(); i++)
    {
      WorkflowFileinbox workflowFileinbox = (WorkflowFileinbox)workflowFileinboxList.get(i);
      try
      {
        if ((workflowFileinbox != null) && 
          (workflowFileinbox.getWorkflowFile().getEndUser() != null))
        {
          User user = this.userManager.getUser(workflowFileinbox.getWorkflowFile().getEndUser().getId());
          createPermException(request, "协同审批->待办公文->签收", getMessage(request, "workflow_show1_label26", "该公文已经被审批人") + user.getName() + getMessage(request, "workflow_show1_label27", "结束！"));
        }
        this.workflowFileinboxManager.savesignSent(workflowFileinbox, request, workflowSignatures);
      }
      catch (Exception e)
      {
        this.logger.error(((WorkflowFileinbox)workflowFileinboxList.get(i)).getWorkflowFile().getTitle() + "批量审批失败!" + e);
      }
    }
    saveMessage(request, getMessage(request, "文件批量审批成功！", "文件批量审批成功！"));
    mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do");
    return mav;
  }
  
  private void backlog(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    map.put("issent_i_in", "1,2");
    








    String inboxSort = org.springside.core.Constants.WORKFLOW_INBOX_SORT;
    if ((!"asc".equals(inboxSort)) && (!"desc".equals(inboxSort))) {
      inboxSort = "desc";
    }
    request.removeAttribute("ec_s_startdate");
    
    Map orderMap = new LinkedHashMap();
    orderMap.put("startdate", inboxSort);
    
    List workflowFileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(map, orderMap);
    

    List workflowFileinboxs = new Vector();
    for (int i = 0; i < workflowFileinboxList.size(); i++)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)workflowFileinboxList.get(i);
      












      int canCheckin = this.workflowFileinboxManager
        .getCanCheckin(workflowFileinbox);
      if (canCheckin == 1) {
        workflowFileinboxs.add(workflowFileinbox);
      }
    }
    mav.addObject("workflowFileinboxs", workflowFileinboxs);
  }
  
  private void postpone(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    mav.addAllObjects(referenceData(request));
    








    map.put("issent_i_eq", "4");
    







    String inboxSort = org.springside.core.Constants.WORKFLOW_INBOX_SORT;
    if ((!"asc".equals(inboxSort)) && (!"desc".equals(inboxSort))) {
      inboxSort = "desc";
    }
    Map orderMap = new LinkedHashMap();
    orderMap.put("startdate", inboxSort);
    mav.addObject("workflowFileinboxs", this.workflowFileinboxManager.findWorkflowFileinbox(map, orderMap));
  }
  
  protected void onQuery(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    







    UserSession user = getUserSession(request);
    









    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_in", "1,2");
    








    String inboxSort = org.springside.core.Constants.WORKFLOW_INBOX_SORT;
    if ((!"asc".equals(inboxSort)) && (!"desc".equals(inboxSort))) {
      inboxSort = "desc";
    }
    request.removeAttribute("ec_s_startdate");
    
    Map orderMap = new LinkedHashMap();
    orderMap.put("startdate", inboxSort);
    
    List workflowFileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(map, orderMap);
    

    List workflowFileinboxs = new Vector();
    for (int i = 0; i < workflowFileinboxList.size(); i++)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)workflowFileinboxList.get(i);
      












      int canCheckin = this.workflowFileinboxManager
        .getCanCheckin(workflowFileinbox);
      if (canCheckin == 1) {
        workflowFileinboxs.add(workflowFileinbox);
      }
    }
    mav.addObject("workflowFileinboxs", workflowFileinboxs);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
    
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
  }
  
  public ModelAndView specialList(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView(this.listView);
    mav.addAllObjects(referenceData(request));
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    






















    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_in", "1,2");
    map.put("isspecial_i_eq", "2");
    
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager.findWorkflowFileinbox(map));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    return mav;
  }
  
  public ModelAndView transfer(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_transfer.jsp");
    




    UserSession userSession = getUserSession(request);
    String inboxId = request.getParameter("id");
    if (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(userSession, inboxId, "5")) {
      createPermException(request, "协同审批->待办公文->转换", null);
    }
    Integer id = new Integer(inboxId);
    try
    {
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(id);
      
      mav.addObject("workflowFileinbox", workflowFileinbox);
    }
    catch (Exception e)
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
    }
    mav.addObject("workflows", this.workflowManager
      .findWorkflow(new HashMap(), userSession));
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    String viewName = UrlUtil.getUrlParams(mav.getViewName(), map, "search_") + "&searchId=" + request.getParameter("searchId");
    mav.setViewName(viewName);
    
    return mav;
  }
  
  /**
   * @deprecated
   */
  public ModelAndView docex(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    throw new BusinessException("无权访问此方法");
  }
  
  public ModelAndView saveBulletin(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    UserSession userSession = getUserSession(request);
    Integer id = new Integer(request.getParameter("id"));
    WorkflowFileinbox workflowFileinbox = null;
    WorkflowFile workflowFile = null;
    try
    {
      workflowFileinbox = 
        this.workflowFileinboxManager.getWorkflowFileinbox(id);
      if (workflowFileinbox.getUser().getId().intValue() != 
        userSession.getId().intValue()) {
        throw new BusinessException("您无权操作此文件");
      }
      workflowFile = workflowFileinbox.getWorkflowFile();
      mav.setViewName("redirect:/modules/bulletin/bulletins.do?method=create&type=workflow&fileId=" + workflowFile.getId() + "&inboxId=" + workflowFileinbox.getId());
      return mav;
    }
    catch (Exception e)
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
    }
    return mav;
  }
  
  public ModelAndView saveDocex(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    UserSession userSession = getUserSession(request);
    
    Integer id = new Integer(request.getParameter("id"));
    if (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(userSession, String.valueOf(id), "3")) {
      createPermException(request, "协同审批->待办公文->传阅", null);
    }
    WorkflowFileinbox workflowFileinbox = null;
    WorkflowFile workflowFile = null;
    try
    {
      workflowFileinbox = 
        this.workflowFileinboxManager.getWorkflowFileinbox(id);
      if (workflowFileinbox.getUser().getId().intValue() != 
        userSession.getId().intValue()) {
        throw new BusinessException("您无权操作此文件");
      }
      workflowFile = workflowFileinbox.getWorkflowFile();
    }
    catch (Exception e)
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
      return mav;
    }
    String docexUser = this.workflowFileinboxManager
      .getDocexUser(workflowFileinbox);
    DocexFile docexFile = new DocexFile();
    

    Date createdate = DateUtil.getDate();
    String title = workflowFile.getTitle();
    String content = "";
    User fromUser = this.userManager.getUser(userSession.getId());
    
    docexFile.setAdditional(Integer.valueOf(1));
    docexFile.setContent("");
    docexFile.setCreatedate(createdate);
    docexFile.setIsConcerm(Integer.valueOf(1));
    docexFile.setIsDraft(Integer.valueOf(1));
    docexFile.setIsShare(Integer.valueOf(1));
    docexFile.setPid(Integer.valueOf(0));
    docexFile.setPriority(Integer.valueOf(3));
    docexFile.setRelationCount(Integer.valueOf(0));
    docexFile.setStatus(Integer.valueOf(0));
    docexFile.setTitle(title);
    docexFile.setUser(fromUser);
    
    docexFile.setIsFree("F");
    String users = "";
    String depts = "";
    if (!"!".equals(docexUser)) {
      users = users.split("!")[0];
    }
    docexFile.setUsers(users);
    docexFile.setDepts(depts);
    docexFile.setFileType(org.springside.core.Constants.DOCEXFILE_TYPE.toString());
    docexFile.setFromType("1");
    













    docexFile.setFromId(workflowFile.getId());
    this.docexFileManager.saveDocexFile(docexFile);
    
    String serverfile = "";
    String filename = "";
    String fileext = "";
    long filesize = 0L;
    
    String attachs = "";
    

    String serverdir = this.docexFileManager.getDocexParentPath(docexFile);
    
    serverdir = serverdir + "/" + docexFile.getId();
    if (!StorageUtil.exists(serverdir)) {
      StorageUtil.mkdir(serverdir);
    }
    for (Object o : workflowFile.getWorkflowFileattaches())
    {
      WorkflowFileattach attach = (WorkflowFileattach)o;
      if ((attach.getType().intValue() == 0) || (
        (attach.getType().intValue() == 1) && (
        attach.getVer().intValue() == attach.getLastver().intValue())))
      {
        String src = attach.getServerfile();
        if (StorageUtil.exists(src))
        {
          String des = serverdir + "/" + DateUtil.getOnlyID();
          StorageUtil.copy(src, des);
          DocexFileattach docexFileattach = new DocexFileattach();
          docexFileattach.setCreatedate(createdate);
          docexFileattach.setDocexFile(docexFile);
          docexFileattach.setFileext(attach.getFileext());
          docexFileattach.setFilename("(" + (attach.getType().intValue() == 0 ? "正文" : "附件") + ")" + attach.getFilename());
          docexFileattach.setFilesize(attach.getFilesize());
          if (docexFileattach.getFilesize() == null) {
            docexFileattach.setFilesize(Integer.valueOf((int)StorageUtil.getSize(src)));
          }
          docexFileattach.setServerfile(des);
          docexFileattach.setUserId(fromUser.getId());
          docexFileattach.setUserName(fromUser.getName());
          
          docexFileattach.setVer(Integer.valueOf(1));
          docexFileattach.setLastver(Integer.valueOf(1));
          




















          docexFileattach.setType(Integer.valueOf(0));
          docexFileattach.setTopicId(UUID.randomUUID().toString());
          filename = attach.getFilename();
          if (filename.toLowerCase().endsWith(".doc")) {
            docexFileattach.setDocType("doc");
          } else if (filename.toLowerCase().endsWith(".docx")) {
            docexFileattach.setDocType("docx");
          } else if ((filename.toLowerCase().endsWith(".xls")) || 
            (filename.toLowerCase().endsWith(".xlsx"))) {
            docexFileattach.setDocType("xls");
          } else {
            docexFileattach.setDocType("unknown");
          }
          docexFileattach.setTopicName("");
          
















          docexFileattach.setFromFlow(Integer.valueOf(1));
          if (attach.getVer().intValue() == attach.getLastver().intValue()) {
            docexFileattach.setIsChecked(Integer.valueOf(1));
          }
          this.docexFileattachManager.saveDocexFileattach(docexFileattach);
        }
      }
    }
    int inboxId = ServletRequestUtils.getIntParameter(request, "inboxId", 0);
    if (workflowFile != null)
    {
      String urlStr = "http://127.0.0.1:" + 
        request.getLocalPort() + 
        request.getContextPath() + 
        "/workflowArchive.do?method=archive&openwin=true&process=false&id=" + 
        
        StrUtils.getEncString(workflowFile.getId().toString()) + "&operationType=controller&inboxId=" + inboxId + "&userId=" + userSession.getId() + "&type=inner";
      
      String fileName = workflowFile.getTitle();
      fileName = fileName.replaceAll("[#$%\\\\/:*?\"<>|\\s]", "-") + 
        ".html";
      
      String serverFile = serverdir + "/" + DateUtil.getOnlyID();
      
      boolean status = false;
      try
      {
        FileUtil.writeHttpFile(urlStr, serverFile);
        status = true;
      }
      catch (Exception e)
      {
        this.logger.info("由于以下错误，表单传阅未能成功！\n" + e);
      }
      if (status)
      {
        DocexFileattach docexFileattach = new DocexFileattach();
        docexFileattach.setDocexFile(docexFile);
        docexFileattach.setUserId(fromUser.getId());
        docexFileattach.setUserName(fromUser.getName());
        docexFileattach.setCreatedate(createdate);
        docexFileattach.setServerfile(serverFile);
        docexFileattach.setFilename("(表单)" + fileName);
        docexFileattach.setFileext("text/plain");
        docexFileattach.setFilesize(Integer.valueOf(
          (int)StorageUtil.getSize(serverFile)));
        
        docexFileattach.setVer(Integer.valueOf(1));
        docexFileattach.setLastver(Integer.valueOf(1));
        




















        docexFileattach.setType(Integer.valueOf(0));
        docexFileattach.setTopicId(UUID.randomUUID().toString());
        docexFileattach.setDocType("unknown");
        docexFileattach.setTopicName("");
        
















        docexFileattach.setFromFlow(Integer.valueOf(1));
        docexFileattach.setIsChecked(Integer.valueOf(1));
        this.docexFileattachManager
          .saveDocexFileattach(docexFileattach);
      }
    }
    String contentFile = serverdir + "/" + "content.htm";
    StorageUtil.writeFile(content, contentFile);
    
    mav
      .setViewName("redirect:/modules/docex/docexFile.do?method=editdraft&id=" + 
      docexFile.getId());
    saveMessage(request, getMessage(request, "KnowledgesManagerController_label91", "流程文件暂存在协同工作草稿箱，可以补充信息后进行发送！"));
    
    return mav;
  }
  
  public ModelAndView saveTransfer(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    Integer id = new Integer(request.getParameter("id"));
    


















    WorkflowFileinbox fileInbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
    if (fileInbox.getWorkflowFile().getFlowFlag().intValue() == 5)
    {
      ModelAndView mav = new ModelAndView();
      saveNullifyMessage(fileInbox.getWorkflowFile(), request);
      mav.setViewName(this.successView);
      return mav;
    }
    String sourceFlowtype = request.getParameter("sourceFlowType");
    

    WorkflowFileinbox workflowFileinbox1 = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    








    this.workflowFileinboxManager.saveApproveOpinion(workflowFileinbox1);
    
    Integer flowId = new Integer(request.getParameter("flowId"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.init(flowId, user);
    













    int tranNum = 0;
    if (workflowFileinbox1.getWorkflowFile().getTranNum() == null) {
      tranNum = 1;
    } else {
      tranNum = workflowFileinbox1.getWorkflowFile().getTranNum().intValue() + 1;
    }
    WorkflowFile wf = workflowFileinbox1.getWorkflowFile();
    wf.setTranNum(Integer.valueOf(tranNum));
    this.workflowFileManager.saveWorkflowFile(wf);
    workflowFileinbox.getWorkflowFile().setTitle(
      request.getParameter("title"));
    if (workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
      .getFilenoAuto() != null) {
      if (workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
        .getFilenoAuto().intValue() == 1)
      {
        WorkflowFileno workflowFileno = this.workflowFileinboxManager
          .saveFileno(workflowFileinbox);
        if (workflowFileno != null) {
          workflowFileinbox.getWorkflowFile().setFileno(
            workflowFileno.getFilenoLast().replace(" @ ", ""));
        }
      }
    }
    if ("1".equals(request.getParameter("isRelation")))
    {
      workflowFileinbox.getWorkflowFile().setFromType(Integer.valueOf(1));
      workflowFileinbox.getWorkflowFile().setFromId(
        workflowFileinbox1.getWorkflowFile().getId());
    }
    else
    {
      workflowFileinbox.getWorkflowFile().setFromType(Integer.valueOf(0));
      workflowFileinbox.getWorkflowFile().setFromId(Integer.valueOf(0));
    }
    this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox, true);
    

    String documentDir = "/workflow/document/" + 
    
      DateUtil.getYearmonth(workflowFileinbox.getWorkflowFile()
      .getSubmitdate());
    if (StorageUtil.exists(documentDir)) {
      StorageUtil.mkdir(documentDir);
    }
    documentDir = 
      documentDir + "/" + String.valueOf(workflowFileinbox.getWorkflow().getId());
    if (StorageUtil.exists(documentDir)) {
      StorageUtil.mkdir(documentDir);
    }
    documentDir = 
      documentDir + "/" + String.valueOf(workflowFileinbox.getWorkflowFile().getId());
    if (StorageUtil.exists(documentDir)) {
      StorageUtil.mkdir(documentDir);
    }
    int document_id = ServletRequestUtils.getIntParameter(request, "document_", 0);
    Map attMap = WebUtils.getParametersStartingWith(request, "attachment_");
    
    Iterator attaches = workflowFileinbox1.getWorkflowFile()
      .getWorkflowFileattaches().iterator();
    while (attaches.hasNext())
    {
      WorkflowFileattach workflowFileattach1 = 
        (WorkflowFileattach)attaches.next();
      if (document_id == workflowFileattach1.getId().intValue())
      {
        WorkflowFileattach workflowFileattach = new WorkflowFileattach();
        workflowFileattach.setCreatedate(DateUtil.getDate());
        workflowFileattach
          .setDescn(getMessage(request, 
          "WorkflowFileinboxManagerController_label2", 
          "来源于知识中心"));
        workflowFileattach.setFileext(workflowFileattach1.getFileext());
        workflowFileattach.setFilename("V1_" + 
          workflowFileattach1.getFilename());
        workflowFileattach.setFilesize(
          workflowFileattach1.getFilesize());
        workflowFileattach.setLastver(Integer.valueOf(1));
        workflowFileattach.setVer(Integer.valueOf(1));
        workflowFileattach.setCheckout(Integer.valueOf(0));
        workflowFileattach.setUserByUserId(
          workflowFileinbox.getWorkflowFile().getUser());
        String filename = workflowFileattach1.getFilename();
        if (filename.lastIndexOf(".") > 0) {
          filename = filename.substring(0, filename.lastIndexOf("."));
        }
        workflowFileattach.setTitle(request.getParameter("title"));
        workflowFileattach.setWorkflowFile(
          workflowFileinbox.getWorkflowFile());
        





















        workflowFileattach.setType(Integer.valueOf(0));
        
        String serverfile = documentDir + "/" + DateUtil.getOnlyID();
        
        StorageUtil.copy(workflowFileattach1.getServerfile(), 
          serverfile);
        workflowFileattach.setServerfile(serverfile);
        this.workflowFileattachManager.saveWorkflowFileattach(
          workflowFileattach, true);
      }
      else if ((attMap != null) && 
        (!attMap.isEmpty()) && 
        (attMap.keySet().contains(
        String.valueOf(workflowFileattach1.getId()))))
      {
        WorkflowFileattach workflowFileattach = new WorkflowFileattach();
        workflowFileattach.setCreatedate(DateUtil.getDate());
        workflowFileattach.setDescn(
        
          getMessage(request, "WorkflowFileinboxManagerController_label3", "来源于工作流转换"));
        workflowFileattach.setFileext(
          workflowFileattach1.getFileext());
        workflowFileattach.setFilename("V1_" + 
          workflowFileattach1.getFilename());
        workflowFileattach.setFilesize(
          workflowFileattach1.getFilesize());
        workflowFileattach.setLastver(Integer.valueOf(1));
        workflowFileattach.setVer(Integer.valueOf(1));
        workflowFileattach.setCheckout(Integer.valueOf(0));
        workflowFileattach.setUserByUserId(
          workflowFileinbox.getWorkflowFile().getUser());
        String filename = workflowFileattach1.getFilename();
        if (filename.lastIndexOf(".") > 0) {
          filename = filename.substring(0, 
            filename.lastIndexOf("."));
        }
        workflowFileattach.setTitle(filename);
        
        workflowFileattach.setWorkflowFile(
          workflowFileinbox.getWorkflowFile());
        





















        workflowFileattach.setType(Integer.valueOf(1));
        
        String serverfile = documentDir + "/" + 
          DateUtil.getOnlyID();
        
        StorageUtil.copy(workflowFileattach1.getServerfile(), 
          serverfile);
        workflowFileattach.setServerfile(serverfile);
        this.workflowFileattachManager.saveWorkflowFileattach(
          workflowFileattach, true);
      }
    }
    if ((sourceFlowtype != null) && (!sourceFlowtype.equals("")))
    {
      WorkflowFileattach workflowFileattach = new WorkflowFileattach();
      workflowFileattach.setCreatedate(DateUtil.getDate());
      workflowFileattach.setDescn(
        getMessage(request, "WorkflowFileinboxManagerController_label3", "来源于工作流转换"));
      
      workflowFileattach.setLastver(Integer.valueOf(1));
      workflowFileattach.setVer(Integer.valueOf(1));
      workflowFileattach.setCheckout(Integer.valueOf(0));
      workflowFileattach.setUserByUserId(
        workflowFileinbox.getWorkflowFile().getUser());
      workflowFileattach.setTitle(
        getMessage(request, "WorkflowFileinboxManagerController_label4", "源表单"));
      workflowFileattach.setWorkflowFile(
        workflowFileinbox.getWorkflowFile());
      





















      workflowFileattach.setType(Integer.valueOf(1));
      String serverFile = "/workflow/document/" + 
      
        DateUtil.getYearmonth(workflowFileinbox.getWorkflowFile()
        .getSubmitdate()) + 
        "/" + 
        String.valueOf(workflowFileinbox.getWorkflow().getId()) + 
        "/" + 
        String.valueOf(workflowFileinbox.getWorkflowFile()
        .getId()) + File.separator + DateUtil.getOnlyID();
      
      FileUtil.writeHttpFile("http://127.0.0.1:" + 
        request.getLocalPort() + 
        request.getContextPath() + 
        "/workflowArchive.do?method=archive&id=" + 
        
        StrUtils.getEncString(String.valueOf(workflowFileinbox1.getWorkflowFile()
        .getId())) + "&operationType=controller&inboxId=" + id + "&userId=" + user.getId(), serverFile);
      workflowFileattach.setServerfile(serverFile);
      workflowFileattach.setFileext("text/plain");
      workflowFileattach
        .setFilename(getMessage(request, 
        "WorkflowFileinboxManagerController_label5", 
        "V1_源表单.html"));
      workflowFileattach.setFilesize(new Integer(String.valueOf(
        new File(org.springside.core.Constants.MAIN_STORAGE_DIR + serverFile).length())));
      this.workflowFileattachManager.saveWorkflowFileattach(
        workflowFileattach, true);
    }
    Map filter = new HashMap();
    filter.put("sourceWorkFlowXXid_i_eq", 
      workflowFileinbox1.getWorkflow().getId().toString());
    filter.put("targetWorkFlowXXid_i_eq", request.getParameter("flowId"));
    List list = this.workflowConvertManager.findWorkflowConvert(filter);
    if ((list != null) && (list.size() > 0))
    {
      ModelAndView mav = new ModelAndView(
        "/modules/workflow/workflow_choicefield.jsp");
      mav.addObject("workflowconvert", list.get(0));
      mav.addObject("sourcebox", workflowFileinbox1);
      mav.addObject("targetbox", workflowFileinbox);
      mav.addObject("oinboxId", id);
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label53", "文件已经保存到草稿箱里了，请选择需要转换过去的字段"));
      return mav;
    }
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
      workflowFileinbox.getId());
    mav.addObject("oinboxId", id);
    return mav;
  }
  
  public ModelAndView saveTransferField(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String[] ids = request.getParameterValues("ids");
    Integer sourceboxid = Integer.valueOf(Integer.parseInt(request.getParameter("sid")));
    Integer targetboxid = Integer.valueOf(Integer.parseInt(request.getParameter("gid")));
    WorkflowFileinbox workflowFileinbox1 = this.workflowFileinboxManager
      .getWorkflowFileinbox(sourceboxid);
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(targetboxid);
    if ((ids != null) && (ids.length > 0)) {
      this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox1, 
        workflowFileinbox, ids);
    }
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
      workflowFileinbox.getId());
    this.workflowFileinboxManager
      .saveWorkflowFileinbox(workflowFileinbox, false);
    mav.addObject("oinboxId", sourceboxid);
    return mav;
  }
  
  public ModelAndView hangup(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView(this.listView);
    mav.addAllObjects(referenceData(request));
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    








    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_eq", "4");
    







    String inboxSort = org.springside.core.Constants.WORKFLOW_INBOX_SORT;
    if ((!"asc".equals(inboxSort)) && (!"desc".equals(inboxSort))) {
      inboxSort = "desc";
    }
    Map orderMap = new LinkedHashMap();
    orderMap.put("startdate", inboxSort);
    mav.addObject("workflowFileinboxs", this.workflowFileinboxManager.findWorkflowFileinbox(map, orderMap));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
    return mav;
  }
  
  public ModelAndView onSearchEdit(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflow_search_edit.jsp");
    

    mav.addObject("title", URLDecoder.decode(request.getParameter("title"), "UTF-8"));
    mav.addObject("userName", URLDecoder.decode(request.getParameter("userName"), "UTF-8"));
    mav.addObject("fileno", URLDecoder.decode(request.getParameter("fileno"), "UTF-8"));
    mav.addObject("deptName", URLDecoder.decode(request.getParameter("deptName"), "UTF-8"));
    mav.addObject("workflowName", URLDecoder.decode(request.getParameter("workflowName"), "UTF-8"));
    mav.addObject("subword", URLDecoder.decode(request.getParameter("subword"), "UTF-8"));
    mav.addObject("catalogy", URLDecoder.decode(request.getParameter("catalogy"), "UTF-8"));
    mav.addObject("classify", URLDecoder.decode(request.getParameter("classify"), "UTF-8"));
    
    return mav;
  }
  
  public ModelAndView onSaveSearch(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflow_search_edit.jsp");
    UserSession user = getUserSession(request);
    WorkflowSearch workflowSearch = new WorkflowSearch();
    bindObject(request, workflowSearch);
    workflowSearch.setUserId(user.getId());
    this.workflowSearchManager.saveOrUpdate(workflowSearch);
    
    Enumeration enu = request.getParameterNames();
    while (enu.hasMoreElements())
    {
      String fieldName = (String)enu.nextElement();
      if (fieldName.startsWith("workflowFileXX"))
      {
        String fieldValue = request.getParameter(fieldName);
        WorkflowSearchField wsf = new WorkflowSearchField();
        wsf.setFieldName(fieldName);
        wsf.setWorkflowSearch(workflowSearch);
        wsf.setFieldValue(fieldValue);
        this.workflowSearchFieldManager.save(wsf);
      }
    }
    mav.addObject("searchId", workflowSearch.getId());
    return mav;
  }
  
  public ModelAndView onRemoveSearch(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    Integer searchType = Integer.valueOf(request.getParameter("searchType"));
    if (org.springside.core.Constants.SEARCH_TYPE_BACKLOG.equals(searchType)) {
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=list&search_classify=1");
    } else if (org.springside.core.Constants.SEARCH_TYPE_TRANSACT.equals(searchType)) {
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=onSearch&search_classify=1&ec_s_sentdate=desc");
    }
    String searchId = request.getParameter("searchId");
    this.workflowSearchManager.remove(Integer.valueOf(searchId));
    return mav;
  }
  
  public ModelAndView onSearch(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_sent.jsp");
    UserSession user = getUserSession(request);
    
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    String searchId = request.getParameter("searchId");
    if ((StringUtils.isNotBlank(searchId)) && (!"null".equals(searchId)))
    {
      WorkflowSearch workflowSearch = this.workflowSearchManager.getWorkflowSearch(Integer.valueOf(searchId));
      
      String search = request.getParameter("search");
      if (StringUtils.isNotBlank(search))
      {
        map = workflowSearch.getSearchMap();
        mav.setViewName(UrlUtil.getUrlParams("/modules/workflow/workflowFileinbox_sent.jsp", map, "search_"));
      }
      else if (this.workflowSearchManager.verifyWorkflowSearch(workflowSearch, map))
      {
        String viewName = mav.getViewName();
        if (viewName.indexOf("?") == -1) {
          viewName = viewName + "?&searchId=";
        }
        mav.setViewName(viewName);
      }
    }
    String classify = (String)map.get("classify");
    
    String messages = request.getParameter("messages");
    if ((StringUtils.isNotBlank(messages)) || (StringUtils.isEmpty(classify)))
    {
      classify = org.springside.core.Constants.CLASSIFY_MYSENT;
      String viewName = mav.getViewName();
      if (viewName.indexOf("?") == -1) {
        viewName = viewName + "?&search_classify=2";
      }
      mav.setViewName(viewName);
    }
    //2015-04-11 流程无法查询问题，可能是名称无法正常过滤引起；
    /*
    if (StringUtils.isNotBlank(request.getParameter("flowIds")))
    {
      map.remove("workflowXXname_s_like");
      map.put("workflowXXid_i_eq", request.getParameter("flowIds"));
    }
    */
    if (org.springside.core.Constants.CLASSIFY_MYDRAFT.equals(classify)) {
      myDraft(request, mav, map);
    } else if (org.springside.core.Constants.CLASSIFY_MYSENT.equals(classify)) {
      mySent(request, mav, map);
    } else if (org.springside.core.Constants.CLASSIFY_MYATTENTION.equals(classify)) {
      myAttention(request, mav, map);
    } else if (org.springside.core.Constants.CLASSIFY_MYAGENT.equals(classify)) {
      myAgent(request, mav, map);
    } else if (org.springside.core.Constants.CLASSIFY_MYSPECIAL.equals(classify)) {
      mySpecial(request, mav, map);
    }else if ("6".equals(classify)) {
    	//fjfdszj 2015-03-21新增不关注逻辑
        myUnAttention(request, mav, map);
    }
    String workflowId = (String)map.get("workflowId");
    if (StringUtils.isNotBlank(workflowId))
    {
      Workflow workflow = this.workflowManager.getWorkflow(Integer.valueOf(workflowId));
      mav.addObject("workflowFlowfieldHtml", this.workflowFlowfieldManager.getWorkflowFlowfieldHtml(workflow.getFlowtypeId(), user));
    }
    mav.addObject("workflowSearchs", this.workflowSearchManager.getWorkflowSearchList(user.getId(), org.springside.core.Constants.SEARCH_TYPE_TRANSACT));
    return mav;
  }
  
  public void myDraft(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    mav.addAllObjects(referenceData(request));
    






    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    PageSortModel psm = new PageSortModel(request, "ec");
    

    map.put("workflowFileXXuserXXid_i_eq", String.valueOf(user.getId()));
    




    map.put("workflowStepXXsteptypeId_i_in", "1,2");
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_in", "3,13,102,104");
    





    String hql = "from WorkflowFileinbox where id in(select max(b.id) from WorkflowFileinbox b where @FILTER_SITE@ group by b.user.id,b.workflowStep.id,b.workflowFile.id)";
    



    List<Object> params = new ArrayList();
    params.add(user.getId());
    params.add(user.getId());
    
    QueryVO queryVO = new QueryVO();
    queryVO.setAhql(hql);
    queryVO.setFilter(map);
    queryVO.setAlias("b");
    
    List<WorkflowFileinbox> workflowFileinboxs = this.workflowFileinboxManager.findWorkflowFileinboxByDivPage(queryVO, psm);
    mav.addObject("workflowFileinboxs", workflowFileinboxs);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    mav.addObject("workflowsort", "myDraft");
  }
  
  public void myAgent(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    mav.addAllObjects(referenceData(request));
    









    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_in", "5,105");
    PageSortModel psm = new PageSortModel(request, "ec");
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager.findWorkflowFileinboxByPage(map, psm));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
  }
  
  public void mySpecial(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    mav.addAllObjects(referenceData(request));
    









    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("isspecial_i_eq", "2");
    map.put("issent_i_not", "1,2,101");
    
    PageSortModel psm = new PageSortModel(request, "ec");
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager.findWorkflowFileinboxByPage(map, psm));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
  }
  
  public void mySent(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    mav.addAllObjects(referenceData(request));
    









    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    map.put("workflowFileXXuserXXid_i_ne", String.valueOf(user.getId()));
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    







    map.put("issent_i_in", "3,102,104");
    PageSortModel psm = new PageSortModel(request, "ec");
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager.findWorkflowFileinboxByPage(map, psm));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
  }
  
  public void myAttention(HttpServletRequest request, ModelAndView mav, Map map)
    throws Exception
  {
    mav.addAllObjects(referenceData(request));
    


    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_in", "3,103");
    map.put("isattention_i_eq", "1");
    PageSortModel psm = new PageSortModel(request, "ec");
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager.findWorkflowFileinboxByPage(map, psm));
    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
    
    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
    

    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
    dict = dict.substring(1, dict.length() - 1);
    
    mav.addObject("workflow_catalogy_dict", dict);
  }
  
  /**
   * 2015-03-21
   * fjfdszj 我不关注的
   * @param request
   * @param mav
   * @param map
   * @throws Exception
   */
  public void myUnAttention(HttpServletRequest request, ModelAndView mav, Map map)
		    throws Exception
		  {
		    mav.addAllObjects(referenceData(request));
		    


		    UserSession user = (UserSession)request.getSession().getAttribute(
		      org.springside.core.Constants.USER_IN_SESSION);
		    map.put("userXXid_i_eq", String.valueOf(user.getId()));
		    map.put("issent_i_in", "3,103");
		    map.put("isattention_i_eq", "0");//0不关注，1关注。
		    PageSortModel psm = new PageSortModel(request, "ec");
		    mav.addObject("workflowFileinboxs", 
		      this.workflowFileinboxManager.findWorkflowFileinboxByPage(map, psm));
		    mav.addObject("priorityMap", org.springside.core.Constants.WORKFLOW_PRIORITY_MAP);
		    
		    String dict = "/" + this.dictManager.findDictByLabel("workflow.catalogy").getOptions() + "/";
		    

		    dict = ("/" + dict + "/").replaceAll("/费用报销/", "/");
		    dict = dict.substring(1, dict.length() - 1);
		    
		    mav.addObject("workflow_catalogy_dict", dict);
		  }
  
  public ModelAndView process(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_process.jsp");
    


    Integer fileId = new Integer(request.getParameter("fileId"));
    
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    
    Integer flowId = workflowFile.getWorkflow().getId();
    
    UserSession userSession = getUserSession(request);
    

    Integer ParentflowId = workflowFile.getWorkflow().getParentId();
    if ((!this.workflowManager.getIsObservers(flowId, userSession)) && 
      (!this.workflowManager.getIsSupervisor(flowId, userSession)) && 
      (!this.workflowFileinboxManager.getIsWorkflowFileUser(userSession, String.valueOf(fileId)))) {
      if (!this.workflowFileManager.isArchiveMan(ParentflowId, userSession)) {
        if (!this.workflowFlowRightManager.getWorkflowPerm(flowId, userSession.getId())) {
          createPermException(request, "协同审批->待办公文->流程信息", null);
        }
      }
    }
    mav.addObject("workflowFile", workflowFile);
    
    mav.addObject("workflowSteps", 
      this.workflowStepManager.findWorkflowStepByFlowId(workflowFile.getWorkflow().getId()));
    
    mav.addObject("workflowFileprocesses", 
      this.workflowFileinboxManager.findWorkflowFileprocess(fileId));
    
    mav.addObject("currentFileinboxes", 
      this.workflowFileinboxManager.findCurrentFileinbox(fileId));
    
    mav.addObject("processStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.processStatusEnum());
    
    mav.addObject("sentStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.sentStatusEnum());
    






    return mav;
  }
  
  public ModelAndView hurry(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_hurry.jsp");
    
    Integer fileId = new Integer(request.getParameter("fileId"));
    

    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    if (workflowFile.getFlowFlag().intValue() == 5)
    {
      saveNullifyMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    if (!StringUtils.isBlank(workflowFile.getEndDesc()))
    {
      endFlowMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    Integer flowId = workflowFile.getWorkflow().getId();
    



















    mav.addObject("workflowFile", workflowFile);
    




















    String title = this.workflowFileinboxManager.formatTitle(workflowFile);
    if (workflowFile.getWorkflow().getCatalogy().equals("费用报销")) {
      title = title + ",待处理,来自[费用报销的催办]";
    } else {
      title = title + getMessage(request, "WorkflowFileinboxManagerController_label8a", ",待处理,来自[公文催办]");
    }
    mav.addObject("titleFormat", title);
    

    List<WorkflowFileinbox> inboxes = this.workflowFileinboxManager
      .findCurrentFileinbox(fileId);
    List<WorkflowFileinbox> workflowFileinboxs = new ArrayList();
    for (WorkflowFileinbox workflowFileinbox : inboxes)
    {
      int canCheckin = this.workflowFileinboxManager
        .getCanCheckin(workflowFileinbox);
      if (canCheckin == 1) {
        workflowFileinboxs.add(workflowFileinbox);
      }
    }
    mav.addObject("currentFileinboxes", workflowFileinboxs);
    
    return mav;
  }
  
  public ModelAndView hurryPopup(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_hurry.jsp");
    
    Integer fileId = new Integer(request.getParameter("fileId"));
    






















    Integer userId = new Integer(request.getParameter("userId"));
    

    Map map = new HashMap();
    map.put("id_i_eq", String.valueOf(fileId));
    List workflowFileList = this.workflowFileManager.findWorkflowFile(map);
    if (workflowFileList.size() > 0)
    {
      WorkflowFile workflowFile = (WorkflowFile)workflowFileList.get(0);
      mav.addObject("workflowFile", workflowFile);
      
      List currentFileinboxeList = this.workflowFileinboxManager
        .findCurrentFileinbox(fileId);
      List currentFileinboxes = new ArrayList();
      for (int i = 0; i < currentFileinboxeList.size(); i++)
      {
        WorkflowFileinbox workflowFileinbox = 
          (WorkflowFileinbox)currentFileinboxeList.get(i);
        if (workflowFileinbox.getUser().getId().intValue() == 
          userId.intValue()) {
          currentFileinboxes.add(workflowFileinbox);
        }
      }
      if (currentFileinboxes.size() == 0) {
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label6", "此文件可能已经被对方处理，不需要进行催办！"));
      }
      mav.addObject("currentFileinboxes", currentFileinboxes);
    }
    else
    {
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label7", "文件可能已经不存在，不需要进行催办了！"));
    }
    return mav;
  }
  
  public ModelAndView monitor(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_monitor.jsp");
    
    Integer fileId = new Integer(request.getParameter("fileId"));
    
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    if (workflowFile.getFlowFlag().intValue() == 5)
    {
      saveNullifyMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    if (!StringUtils.isBlank(workflowFile.getEndDesc()))
    {
      endFlowMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    Integer flowId = workflowFile.getWorkflow().getId();
    if ((!this.workflowManager.getIsObservers(flowId, userSession)) && 
      (!this.workflowManager.getIsSupervisor(flowId, userSession)) && 
      (!this.workflowFileinboxManager.getIsWorkflowFileUser(userSession, String.valueOf(fileId)))) {
      createPermException(request, "协同审批->待办公文->督办", null);
    }
    mav.addObject("workflowFile", workflowFile);
    
























































    String title = this.workflowFileinboxManager.formatTitle(workflowFile);
    if (workflowFile.getWorkflow().getCatalogy().equals("费用报销")) {
      title = title + ",待处理,来自[费用报销的督办]";
    } else {
      title = title + getMessage(request, "workflowFileinbox_monitor_label10a", ",待处理,来自[公文督办]");
    }
    mav.addObject("titleFormat", title);
    
    List currentFileinboxes = this.workflowFileinboxManager
      .findCurrentFileinbox(fileId);
    

























    List receiveList = new ArrayList();
    for (int i = 0; i < currentFileinboxes.size(); i++)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)currentFileinboxes.get(i);
      List memberList = this.systemPositionmemberManager
        .findSuperior(workflowFileinbox.getUser().getId());
      for (int j = 0; j < memberList.size(); j++)
      {
        SystemPositionmember systemPositionmember = 
          (SystemPositionmember)memberList.get(j);
        User u = systemPositionmember.getUser();
        if (u.getStatus().equals("1"))
        {
          String tempStr = u.getId() + "!" + 
            u.getName() + "!" + 
            workflowFileinbox.getUser().getId() + "!" + 
            workflowFileinbox.getUser().getName();
          if ((receiveList.isEmpty()) || (!receiveList.contains(tempStr))) {
            receiveList.add(tempStr);
          }
        }
      }
    }
    mav.addObject("receiveList", receiveList);
    
    return mav;
  }
  
  public ModelAndView saveHurry(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer fileId = new Integer(request.getParameter("fileId"));
    

    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    if (workflowFile.getFlowFlag().intValue() == 5)
    {
      ModelAndView mav = new ModelAndView();
      saveNullifyMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    if (!StringUtils.isBlank(workflowFile.getEndDesc()))
    {
      ModelAndView mav = new ModelAndView();
      endFlowMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    Integer flowId = workflowFile.getWorkflow().getId();
    SystemHierarchy systemHierarchy = workflowFile.getWorkflow().getSystemHierarchy();
    





















    String fileTitleName = workflowFile.getTitle();
    

    ModelAndView mav = new ModelAndView(
      "redirect:/modules/workflow/workflowFileinbox.do?method=hurry&fileId=" + 
      fileId + "&openwin=true");
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    String users = request.getParameter("users");
    








    String title = request.getParameter("title");
    String content = request.getParameter("content");
    String usernames = request.getParameter("usernames");
    





    String sms = request.getParameter("sms");
    if ((sms == null) || ("".equals(sms))) {
      sms = "0";
    }
    this.workflowFileinboxManager1.saveWorkflwoHurryMessages(fileId, users, user, 
      title, content, Integer.parseInt(sms));
    
    saveMessage(request, 
      getMessage(request, "WorkflowFileinboxManagerController_label9", "已经发催办送消息给：") + 
      usernames);
    return mav;
  }
  
  public ModelAndView saveMonitor(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer fileId = new Integer(request.getParameter("fileId"));
    
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    if (workflowFile.getFlowFlag().intValue() == 5)
    {
      ModelAndView mav = new ModelAndView();
      saveNullifyMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    if (!StringUtils.isBlank(workflowFile.getEndDesc()))
    {
      ModelAndView mav = new ModelAndView();
      endFlowMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    Integer flowId = workflowFile.getWorkflow().getId();
    if ((!this.workflowManager.getIsObservers(flowId, userSession)) && 
      (!this.workflowManager.getIsSupervisor(flowId, userSession)) && 
      (!this.workflowFileinboxManager.getIsWorkflowFileUser(userSession, String.valueOf(fileId)))) {
      createPermException(request, "协同审批->待办公文->督办", null);
    }
    String fileTitleName = workflowFile.getTitle();
    

    ModelAndView mav = new ModelAndView(
      "redirect:/modules/workflow/workflowFileinbox.do?method=monitor&fileId=" + 
      fileId + "&openwin=true");
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    String[] checks = request.getParameterValues("check_user");
    String title = request.getParameter("title");
    



    String content = request.getParameter("content");
    
    String userNames = "";
    






















    String sms = request.getParameter("sms");
    if ((sms == null) || ("".equals(sms))) {
      sms = "0";
    }
    for (int i = 0; i < checks.length; i++)
    {
      String users = request.getParameter("receiver_user" + checks[i]);
      if ((users != null) && (!"".equals(users)))
      {
        String[] u = users.split("!");
        if ("".equals(userNames)) {
          userNames = u[1];
        } else {
          userNames = userNames + "," + u[1];
        }
        String url = "#\" onclick=\"javascript:openwin('../workflow/workflowFileinbox.do?method=hurryPopup&userId=" + 
          u[2] + 
          "&fileId=" + 
          fileId + 
          "&openwin=true',50,100,840,480,'yes');\"";
        














        Map<String, String> filter = new HashMap();
        filter.put("userXXid_i_eq", u[2]);
        filter.put("workflowFileXXid_i_eq", fileId.toString());
        filter.put("issent_i_in", "1,2,4");
        
        List<WorkflowFileinbox> workflowFileinboxs = this.workflowFileinboxManager
          .findWorkflowFileinbox(filter);
        
        this.workflowFileinboxManager1.saveWorkflowMonitorMessages(u[0], 
          user, title, content, url, 
          ((WorkflowFileinbox)workflowFileinboxs.get(0)).getClass().getName(), 
          ((WorkflowFileinbox)workflowFileinboxs.get(0)).getId(), Integer.parseInt(sms));
      }
    }
    saveMessage(request, 
      getMessage(request, "WorkflowFileinboxManagerController_label12", "已经发督办送消息给：") + 
      userNames);
    return mav;
  }
  
  public ModelAndView scan(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_scan.jsp");
    mav.addAllObjects(referenceData(request));
    onScan(request, response, mav);
    return mav;
  }
  
  protected void onScan(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Integer flowId = new Integer(request.getParameter("flowId"));
    
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.init(
      flowId, user);
    
    mav.addObject("workflowFileinbox", workflowFileinbox);
    























    Map map = new HashMap();
    map.put("flowtypeId_i_eq", String.valueOf(
      workflowFileinbox.getWorkflowFile().getWorkflowFlowtype().getId()));
    map.put("status_i_eq", "1");
    map.put("inputtype_s_eq", "text");
    

    mav.addObject("workflowFlowfields", 
      this.workflowFlowfieldManager.findWorkflowFlowfield(map));
  }
  
  public ModelAndView scanSave(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=");
    onSave(request, response, mav, true, true);
    return mav;
  }
  
  public ModelAndView create(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_new.jsp");
    mav.addAllObjects(referenceData(request));
    



    onCreateNew(request, response, mav);
    return mav;
  }
  
  protected void onCreate(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Integer flowId = new Integer(request.getParameter("flowId"));
    
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.init(
      flowId, user);
    if (workflowFileinbox.getWorkflowStep().getName().equals("报销分摊开始"))
    {
      mav.addObject("SHOW_BAOXIAOFENTAN", "yes");
      



















      Map<String, String> filter = new HashMap();
      filter.put("flowtypeId_i_eq", 
        workflowFileinbox.getWorkflow().getFlowtypeId().toString());
      List<WorkflowFlowfield> fields = this.workflowFlowfieldManager
        .findWorkflowFlowfield(filter);
      for (WorkflowFlowfield field : fields) {
        if ("报销类型".equals(field.getName()))
        {
          String fname = field.getFieldtype() + field.getDatatype() + 
            field.getFieldserial();
          mav.addObject("bxlx", fname);
        }
        else
        {
          if (",报销内容摘要,金额,备注,".contains("," + field.getName() + 
            ",")) {
            if (field.getFieldtype().equals("list"))
            {
              String fname = "listZZfieldstr" + field.getFieldserial() + 
                "ZZ";
              if ("报销内容摘要".equals(field.getName()))
              {
                mav.addObject("bxnrzy", fname); continue;
              }
              if ("金额".equals(field.getName()))
              {
                mav.addObject("je", fname); continue;
              }
              mav.addObject("bz", fname); continue;
            }
          }
          if ("合计金额".equals(field.getName()))
          {
            String fname = "fieldstr" + field.getFieldserial();
            mav.addObject("hjje", fname);
          }
          else if ("报销日期".equals(field.getName()))
          {
            ReflectUtil.setClassAttributeValue(
              workflowFileinbox.getWorkflowFile(), "fieldstr" + 
              field.getFieldserial(), 
              new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
          }
        }
      }
    }
    if (workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
      .getFilenoAuto() != null) {
      if (workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
        .getFilenoAuto().intValue() == 1) {
        try
        {
          WorkflowFileno workflowFileno = this.workflowFileinboxManager
            .saveFileno(workflowFileinbox);
          if ((workflowFileno != null) && 
            (!StringUtils.isBlank(workflowFileno.getFilenoLast())))
          {
            String[] fileno = workflowFileno.getFilenoLast().split("@");
            



































            int fileNoStart = workflowFileinbox.getWorkflowFile().getWorkflowFlowtype().getFilenoStart().intValue();
            if ((workflowFileno.getFilenoValue() != null) && (fileNoStart > workflowFileno.getFilenoValue().intValue()))
            {
              String newFileNo = "";
              String format = "%03d";
              if (fileno[1] != null)
              {
                int len = fileno[1].trim().length();
                if (len > 3) {
                  format = "%0" + len + "d";
                }
              }
              try
              {
                newFileNo = String.format(format, new Object[] { Integer.valueOf(fileNoStart) });
              }
              catch (Exception e)
              {
                System.out.println("格式化起始编号异常：" + e.getMessage());
              }
              if (!StringUtils.isBlank(newFileNo))
              {
                workflowFileinbox.getWorkflowFile().setFileno(newFileNo);
                workflowFileno = this.workflowFileinboxManager.saveFileno(workflowFileinbox, Integer.valueOf(fileNoStart));
              }
            }
            else if (fileno.length == 3)
            {
              workflowFileinbox.getWorkflowFile().setFileno(
                fileno[0].trim() + fileno[1].trim() + 
                fileno[2].trim());
            }
          }
        }
        catch (BusinessException e)
        {
          e.printStackTrace();
        }
      }
    }
    if ((workflowFileinbox.getWorkflow().getIsIntegration() != null) && 
      (workflowFileinbox.getWorkflow().getIsIntegration().intValue() == 1))
    {
      String errorMsg = this.workflowIntegrationManager
        .getIntegrationData(workflowFileinbox.getWorkflowFile(), 
        workflowFileinbox.getWorkflowStep());
      if (StringUtils.isNotEmpty(errorMsg)) {
        saveMessage(request, errorMsg);
      }
    }
    this.workflowFileinboxManager.handleSystemDate(workflowFileinbox);
    this.workflowFileinboxManager.handleSystemTime(workflowFileinbox);
    
    mav.addObject("workflowFileinbox", workflowFileinbox);
    




















    mav.addObject("workflowFile", workflowFileinbox.getWorkflowFile());
    




















    String base = this.workflowFlowtypeManager.getDesignbase(
      workflowFileinbox.getWorkflow().getFlowtypeId(), "");
    




















    String content = this.workflowFlowtypeManager.getDesignbaseContent(
      workflowFileinbox.getWorkflow().getFlowtypeId(), "");
    
    mav.addObject("dynamicForm", this.workflowFlowtypeManager
      .getDynamicForm(workflowFileinbox, false, user, content));
    
    mav.addObject("printtemplates", 
      this.workflowFlowtypeManager
      .findWordtemplateByType(workflowFileinbox.getWorkflow().getFlowtypeId(), Integer.valueOf(3)));
  }
  
  protected void onEdit(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    
    String webIMIsIframe = request.getParameter("webIMIsIframe");
    mav.addObject("webIMIsIframe", webIMIsIframe);
    String uploadres = request.getParameter("uploadres");
    if ((StringUtils.isNotEmpty(uploadres)) && (uploadres.equals("-1"))) {
      saveMessage(request, getMessage(request, "上传文件大小不能为0!", "上传文件大小不能为0!"));
    }
    if ("true".equalsIgnoreCase(org.springside.core.Constants.WORKFLOW_AUTOSIGN))
    {
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
      if ((workflowFileinbox.getIssent().intValue() == 2) || 
        (workflowFileinbox.getIssent().intValue() == 4)) {
        onEdit(request, response, mav, id);
      } else if ((workflowFileinbox.getIssent().intValue() == 1) && 
        (this.workflowFileinboxManager.getCanCheckin(workflowFileinbox) == 1))
      {
        if (this.workflowFileinboxManager.saveCheckin(id))
        {
          onEdit(request, response, mav, id);
        }
        else
        {
          mav = new ModelAndView("/modules/workflow/workflowFileinbox_finish.jsp");
          mav.addObject("isSuccess", Integer.valueOf(1));
          saveMessage(request, 
            getMessage(request, 
            "WorkflowFileinboxManagerController_label80", 
            "附件大小不能為0！"));
        }
      }
      else if (workflowFileinbox.getIssent().intValue() == 9) {
        onEdit(request, response, mav, id);
      } else {
        mav.setViewName("/modules/workflow/workflowFileinbox.do?method=show&id=" + id);
      }
    }
    else
    {
      onEdit(request, response, mav, id);
    }
  }
  
  protected void onEdit(HttpServletRequest request, HttpServletResponse response, ModelAndView mav, Integer id)
    throws Exception
  {
    UserSession userSession = getUserSession(request);
    

    WorkflowFileinbox fileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
    if ((fileinbox != null) && 
      (fileinbox.getWorkflowFile().getEndUser() != null))
    {
      User user = this.userManager.getUser(fileinbox.getWorkflowFile().getEndUser().getId());
      createPermException(request, "协同审批->待办公文->签收", getMessage(request, "workflow_show1_label26", "该公文已经被审批人") + user.getName() + getMessage(request, "workflow_show1_label27", "结束！"));
    }else{
    	//2014-01-03 变更办结可修改处理 begin
  		Map filter3 = new HashMap();
  		filter3.put("workflowFileinboxXXid_i_eq",id);
  		filter3.put("status_i_in","4,5");
  		List chanagelist = this.workflowFileChangeManager.findWorkflowFileChange(filter3);
  		if(chanagelist!=null && chanagelist.size()>0){
//  			WorkflowFileChange workflowFileChange=(WorkflowFileChange)chanagelist.get(0);
//  			workflowFileChange.setStatus(Integer.valueOf(5));
//     			workflowFileChange.setPrintTime(DateUtil.getDate());
//  			workflowFileChangeManager.saveWorkflowFileChange(workflowFileChange);
  		}else if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(id))) {
  	      createPermException(request, "协同审批->待办公文->编辑", null);
  	    }
        //2014-01-03 变更办结可修改处理 end 
    }	
    
    Map map = new HashMap();
    map.put("id_i_eq", String.valueOf(id));
    List workflowFileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(map);
    
    String returnView = this.editView;
    

    mav.addObject("isHaveDocexPerm", Boolean.valueOf(this.docexFileManager.isHaveDocexPerm(this.userManager.getUser(userSession.getId()))));
    mav.addObject("isHaveBulletinAdd", Boolean.valueOf((AuthUtils.isAuthorized("AUTH_MODULES_BULLETIN_ADD")) || (AuthUtils.isAuthorized("AUTH_MODULES_BULLETIN_ADMIN"))));
    if (workflowFileinboxList.size() > 0)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)workflowFileinboxList.get(0);
      




















      List<WorkflowStep> nextStepList = this.workflowFileinboxManager
        .getNextStep(workflowFileinbox);
      Map orderMap = new LinkedHashMap();
      orderMap.put("posy", "asc");
      orderMap.put("posx", "asc");
      Collections.sort(nextStepList, ObjectComparator.instance(orderMap));
      mav.addObject("nextSteps", nextStepList);
      mav.addObject("workflowStepInfoMap", this.workflowStepManager.findWorkflowStepInfoByFlowIdToMap(workflowFileinbox.getWorkflow().getId()));
      

      Map FileattachUploader = new HashMap();
      FileattachUploader = this.workflowFileattachManager.getAttachUploder(id.intValue());
      mav.addObject("FileattachUploader", FileattachUploader);
      









      Map condition = new HashMap();
      condition.put("workflowFileXXid_i_eq", 
        String.valueOf(workflowFileinbox.getWorkflowFile().getId()));
      condition.put("issent_i_in", "1,2,3,13,4");
      Map order = new HashMap();
      order.put("id", "asc");
      List<WorkflowFileinbox> inboxList = this.workflowFileinboxManager
        .findWorkflowFileinbox(condition, order);
      Map<Integer, WorkflowStep> linkMap = new LinkedHashMap();
      for (WorkflowFileinbox box : inboxList) {
        linkMap.put(box.getWorkflowStep().getId(), 
          box.getWorkflowStep());
      }
      List<String> stepInfoList = new ArrayList();
      Object set = linkMap.keySet();
      String stepName = "";
      StringBuffer sb = null;
      for (Integer stepId : (Set<Integer>)set)
      {
        sb = new StringBuffer();
        for (WorkflowFileinbox box : inboxList) {
          if (stepId.intValue() == 
            box.getWorkflowStep().getId().intValue())
          {
            stepName = box.getWorkflowStep().getName();
            String html = "";
            if (box.getIssent().intValue() == 1) {
              html = 
                "<font color='#FF00FF'>" + box.getUser().getName() + "</font>";
            } else if ((box.getIssent().intValue() == 2) || (box.getIssent().intValue() == 4)) {
              html = 
                "<font color='#2BBF50'>" + box.getUser().getName() + "</font>";
            } else if (box.getIssent().intValue() == 3) {
              html = 
                "<font color='#333333'>" + box.getUser().getName() + "</font>";
            } else if (box.getIssent().intValue() == 13) {
              html = 
                "<font color='#333333'>" + box.getUser().getName() + "</font>";
            }
            sb.append(html).append("、");
          }
        }
        if (sb.length() > 0) {
          sb.deleteCharAt(sb.length() - 1);
        }
        String pos = String.valueOf(((WorkflowStep)linkMap.get(stepId)).getPosy()) + 
          "," + String.valueOf(((WorkflowStep)linkMap.get(stepId)).getPosx());
        stepInfoList.add(pos + "," + stepName + "," + sb.toString());
      }
      Collections.sort(stepInfoList, new Comparator()
      {
        public int compare(Object arg0, Object arg1)
        {
          String o1=arg0.toString();
          String o2=arg1.toString();
          int a = Integer.parseInt(o1.split(",")[0]);
          int b = Integer.parseInt(o2.split(",")[0]);
          int c = Integer.parseInt(o1.split(",")[1]);
          int d = Integer.parseInt(o2.split(",")[1]);
          if (a - b != 0) {
            return a - b;
          }
          return c - d;
        }
      });
      mav.addObject("allStepInfo", stepInfoList);
      mav.addObject("currentFileinboxes", 
        this.workflowFileinboxManager
        .findCurrentFileinbox(workflowFileinbox.getWorkflowFile().getId()));
      


      Map filter2 = new HashMap();
      filter2.put("userByUserIdXXid_i_eq", 
        String.valueOf(workflowFileinbox.getUser().getId()));
      filter2.put("entityId_i_eq", String.valueOf(
        workflowFileinbox.getId()));
      filter2.put("entityClass_s_eq", 
        workflowFileinbox.getClass().getName());
      filter2.put("isread_i_eq", "0");
      
      List messagesList = this.messagesManager.findMessages(filter2);
      if (messagesList.size() > 0)
      {
        Messages messages = (Messages)messagesList.get(0);
        messages.setIsread(Integer.valueOf(1));
      }
      if (workflowFileinbox.getWorkflow().getEditStyle().intValue() == 0) {
        returnView = this.editView;
      } else {
        returnView = "/modules/workflow/workflowFileinbox_edit_mulit.jsp";
      }
      mav.setViewName(returnView);
      

      boolean isCanEdit = false;
      if (this.workflowFilelockManager.saveWorkflowFilelock(workflowFileinbox, "edit")) {
        isCanEdit = true;
      }
      User user = this.userManager.getUser(userSession.getId());
      Set<Role> roles = user.getRoles();
      if (workflowFileinbox.getWorkflowStep().getName().equals("公文交换")) {
        for (Role role : roles)
        {
          boolean flag = false;
          Set<Permission> perms = role.getPermissions();
          for (Permission perm : perms) {
            if (perm.getName().equals("AUTH_MODULES_GWJH"))
            {
              mav.addObject("AUTH_MODULES_GWJH", "yes");
              flag = true;
              break;
            }
          }
          if (flag) {
            break;
          }
        }
      }
      String linkUrl = getWSSPUrl(request);
      if (linkUrl != null)
      {
        mav.addObject("linkUrl", linkUrl);
        mav.addObject("AUTH_MODULES_GWJH_WSSP", "yes");
      }
      this.workflowFileinboxManager.convertWorkflowFile(
        workflowFileinbox.getWorkflowFile(), workflowFileinbox);
      if ((workflowFileinbox.getWorkflow().getIsIntegration() != null) && 
        (workflowFileinbox.getWorkflow().getIsIntegration().intValue() == 1))
      {
        String errorMsg = this.workflowIntegrationManager
          .getIntegrationData(workflowFileinbox
          .getWorkflowFile(), 
          workflowFileinbox.getWorkflowStep());
        if (StringUtils.isNotEmpty(errorMsg)) {
          saveMessage(request, errorMsg);
        }
      }
      this.workflowFileinboxManager.handleSystemTime(workflowFileinbox);
      this.workflowFileinboxManager.handleSystemDate(workflowFileinbox);
      



      WorkflowFile file = workflowFileinbox.getWorkflowFile();
      WorkFlowUtil.removeEmptyFile(file);
      
      mav.addObject("workflowFile", file);
      



















      mav.addObject("workflowFileinbox", workflowFileinbox);
      if ((workflowFileinbox.getIsspecial().intValue() == 2) && 
        (workflowFileinbox.getFromId() != null) && 
        (!workflowFileinbox.getFromId().toString().equals(""))) {
        mav.addObject("specialWorkflowFileinbox", this.workflowFileinboxManager.getWorkflowFileinbox(workflowFileinbox.getFromId()));
      }
      if ((workflowFileinbox.getIssent().intValue() == 1) || 
        (workflowFileinbox.getIssent().intValue() == 2))
      {
        Date nowDate = new Date();
        if ((workflowFileinbox.getWorkflowStep().getDays() != null) && 
          (workflowFileinbox.getWorkflowStep().getDays().intValue() != 0))
        {
          int internal = workflowFileinbox.getWorkflowStep()
            .getDays().intValue() * 60;
          
          Date termDate = this.systemWorkhourManager.getBusinessTime(
            workflowFileinbox.getUser(), 
            workflowFileinbox.getStartdate(), Integer.valueOf(internal));
          if (nowDate.compareTo(termDate) > 0) {
            saveMessage(
              request, 
              getMessage(
              request, 
              "WorkflowFileinboxManagerController_label60", 
              "该文件已超过办理期限，请抓紧时间办理！"));
          }
        }
        else if ((workflowFileinbox.getWishdate() != null) && 
          (nowDate.compareTo(workflowFileinbox.getWishdate()) > 0))
        {
          saveMessage(
            request, 
            getMessage(
            request, 
            "WorkflowFileinboxManagerController_label60", 
            "该文件已超过办理期限，请抓紧时间办理！"));
        }
      }
      if ("".equals(this.workflowFlowtypeManager
        .getWorkflowTemplate(workflowFileinbox.getWorkflowFile(), ""))) {
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label22", "模板文件不存在，请联系系统管理员！"));
      }
      String content = this.workflowFlowtypeManager
        .getWorkflowTemplateContent(workflowFileinbox
        .getWorkflowFile(), "");
      Pattern pattern = Pattern.compile("(<textarea.*?>)(.*?)(</textarea>)", 32);
      Matcher matcher = pattern.matcher(content);
      StringBuffer buffer = new StringBuffer();
      while (matcher.find()) {
        matcher.appendReplacement(buffer, "$1$3");
      }
      matcher.appendTail(buffer);
      content = buffer.toString();
      if (isCanEdit)
      {
        boolean showSign = ServletRequestUtils.getBooleanParameter(request, "showSign", true);
        mav.addObject("dynamicForm", this.workflowFlowtypeManager.getDynamicForm(workflowFileinbox, false, userSession, content, showSign));
      }
      else
      {
        String message = this.workflowFilelockManager.getMessage();
        mav.setViewName("/modules/workflow/workflowFileinbox.do?method=show&id=" + id);
        saveMessage(request, message);
        
        mav.addObject("dynamicForm", this.workflowFlowtypeManager.getDynamicForm(workflowFileinbox, true, userSession, content));
      }
      mav.addObject("canReturn", 
        Integer.valueOf(this.workflowFileinboxManager.getCanReturn(workflowFileinbox)));
      

      mav.addObject("canPrint", 
      
        Integer.valueOf(this.workflowFlowtypeManager.existWorkflowTemplate(workflowFileinbox.getWorkflowFile(), "print")));
      if ((workflowFileinbox.getWorkflowFile().getFromId() != null) && 
        (workflowFileinbox.getWorkflowFile().getFromId().intValue() != 0)) {
        if (workflowFileinbox.getWorkflowFile().getFromType().intValue() < 3)
        {
          WorkflowFile workflowFile = null;
          try
          {
            workflowFile = 
              this.workflowFileManager.getWorkflowFile(workflowFileinbox
              .getWorkflowFile().getFromId());
            

















            mav.addObject("relationFileId", StrUtils.getEncString(
              workflowFileinbox.getWorkflowFile().getFromId().toString()));
          }
          catch (Exception e)
          {
            this.logger.info("关联公文已被删除，ID:" + 
              workflowFileinbox.getWorkflowFile().getId());
          }
          if (workflowFile != null) {
            mav.addObject("relationFile", workflowFile);
          }
        }
      }
      if ((workflowFileinbox.getLeaveword() != null) && 
        (!"".equals(workflowFileinbox.getLeaveword()))) {
        saveMessage(request, workflowFileinbox.getLeaveword());
      }
      if (this.workflowSpecManager.checkStep(id)) {
        mav.addObject("stepInfo", 
          this.workflowSpecManager.getStepInfo(id));
      }
      Map filter = new HashMap();
      filter.put("userId_i_eq", String.valueOf(user.getId()));
      mav.addObject("workflowShortopinions", 
        this.workflowShortopinionManager
        .findWorkflowShortopinion(filter));
      
































      Map<String, String> optionFilter = new HashMap();
      optionFilter.put("userXXid_i_eq", String.valueOf(user.getId()));
      optionFilter.put("fileId_i_eq", String.valueOf(
        workflowFileinbox.getWorkflowFile().getId()));
      optionFilter.put("stepId_i_eq", String.valueOf(
        workflowFileinbox.getWorkflowStep().getId()));
      optionFilter.put("signField_s_like", "detail");
      WorkflowFileopinion workflowFileopinion = this.workflowFileinboxManager.findWorkflowFileopinion(optionFilter);
      if (workflowFileopinion != null) {
        mav.addObject("isHasOption", "yes");
      } else {
        mav.addObject("isHasOption", "no");
      }
      //===================2015-01-20======================
    //2014-01-04 办结文件可修改且保存状态。 begin
		if ("FIRSTHXSM".equalsIgnoreCase(org.springside.core.Constants.PROJECT_NAME)) {
			Map filter3 = new HashMap();
			filter3.put("workflowFileinboxXXid_i_eq",
					workflowFileinbox.getId());
			List chanagelist = this.workflowFileChangeManager.findWorkflowFileChange(filter3);
			String message = "";
			if ((chanagelist != null) && (chanagelist.size() > 0)) {
				boolean flag = true;
				for (int i = 0; i < chanagelist.size(); i++) {
					WorkflowFileChange chanageinfo = (WorkflowFileChange) chanagelist.get(i);
					if (chanageinfo.getStatus().intValue() != 5) {
						flag = false;
						if (chanageinfo.getStatus().intValue() == 4) {
							message = "你申请的文件变更已经被同意了!";
						}
						if (chanageinfo.getStatus().intValue() == 2) {
							message = "此文件正在申请文件变更！";
						}
						if (chanageinfo.getStatus().intValue() == 3) {
							message = "此文件变更申请被拒绝！";
						}
						mav.addObject("workflowFileChange", chanageinfo);
						mav.addObject("changeInfo", message);
						break;
					}
				}
				if (flag) {
					WorkflowFileChange chanageinfo = (WorkflowFileChange) chanagelist.get(chanagelist.size() - 1);
					message = "此文件已经变更处理过！";
					mav.addObject("changeInfo", message);
					mav.addObject("workflowFileChange", chanageinfo);
				}
			}
		   //2014-01-04 办结文件可修改且保存状态。end
		}
      //==================================================
      if ("FIRSTHXSM".equalsIgnoreCase(org.springside.core.Constants.PROJECT_NAME))
      {
        Map filter3 = new HashMap();
        filter3.put("workflowFileinboxXXid_i_eq", 
          workflowFileinbox.getId());
        List printlist = this.workflowFilePrintInfoManager
          .findWorkflowFilePrintInfo(filter3);
        String message = "";
        if ((printlist != null) && (printlist.size()==1))
        {
          WorkflowFilePrintInfo printinfo = 
            (WorkflowFilePrintInfo)printlist.get(0);
          mav.addObject("workflowFilePrintInfo", printinfo);
          if (printinfo.getStatus() != null)
          {
            if (printinfo.getStatus().intValue() == 4) {
              message = "你的申请已经被同意了";
            }
            if (printinfo.getStatus().intValue() == 5) {
              message = "此文件已经被打印";
            }
            if (printinfo.getStatus().intValue() == 2) {
              message = "此文件正在申请打印中";
            }
            if (printinfo.getStatus().intValue() == 3) {
              message = "此文件打印申请被拒绝！";
            }
            mav.addObject("printInfo", message);
          }
        }
        else if (printlist.size() >= 2)
        {
        	 boolean flag=true;
          for (int i = 0; i < printlist.size(); i++)
          {
            WorkflowFilePrintInfo printinfo = 
              (WorkflowFilePrintInfo)printlist.get(i);
            if (printinfo.getStatus().intValue() != 5)
            {
            	 flag=false;
              if (printinfo.getStatus().intValue() == 4) {
                message = "你的申请已经被同意了";
              }
              if (printinfo.getStatus().intValue() == 2) {
                message = "此文件正在申请打印中";
              }
              if (printinfo.getStatus().intValue() == 3) {
                message = "此文件打印申请被拒绝！";
              }
              mav.addObject("workflowFilePrintInfo", printinfo);
              mav.addObject("printInfo", message);
              break;
            }
          }
          //当超过二次时，标识全为5，说明已经被打印
          if(flag){
        	  WorkflowFilePrintInfo printinfo = (WorkflowFilePrintInfo)printlist.get(printlist.size()-1);
        	  message = "此文件已经被打印";
        	  mav.addObject("printInfo", message);
        	  mav.addObject("workflowFilePrintInfo", printinfo);
          }
        }
        String userid = workflowFileinbox.getWorkflow()
          .getSuperprinters();
        if ((userid != null) && (!userid.equals("")))
        {
          Map filter1 = new HashMap();
          filter1.put("id_i_in", userid);
          mav.addObject("applyUsers", this.userManager.findUser(filter1));
        }
      }
      Set<User> attentionUsers = workflowFileinbox.getWorkflowFile()
        .getAttentionUsers();
      if (attentionUsers.contains(this.userManager.getUser(userSession.getId()))) {
        mav.addObject("attention", "true");
      }
      mav.addObject("printtemplates", 
        this.workflowFlowtypeManager
        .findWordtemplateByType(workflowFileinbox.getWorkflow().getFlowtypeId(), Integer.valueOf(3)));
      if ((workflowFileinbox.getWorkflow().getIsIntegration() != null) && 
        (workflowFileinbox.getWorkflow().getIsIntegration().intValue() == 1))
      {
        List<WorkflowOperation> operations = this.workflowOperationManager
          .findWorkflowOperation(workflowFileinbox
          .getWorkflowStep().getId());
        mav.addObject("workflowOperations", operations);
      }
      String allActions = this.workflowStepManager.getAllWorkflowStepActionsByUser(workflowFileinbox, getUserSession(request));
      mav.addObject("allActions", allActions);
      

      mav.addObject("knowledgesList", this.workflowKnowledgeManager.getWorkflowKnowledgeList(workflowFileinbox.getWorkflow().getId()));
    }
    else
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label23", "此文件已经被流程监控员删除！"));
    }
  }
  
  public ModelAndView applyprint(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    UserSession userLogin = (UserSession)request.getSession()
      .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
    Integer id = new Integer(request.getParameter("id"));
    String applyuserid = request.getParameter("applyUser");
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    WorkflowFilePrintInfo printinfo = null;
    if ((request.getParameter("pid") != null) && 
      (!"".equals(request.getParameter("pid"))))
    {
      Integer pid = Integer.valueOf(Integer.parseInt(request.getParameter("pid")));
      printinfo = this.workflowFilePrintInfoManager
        .getWorkflowFilePrintInfo(pid);
      if (printinfo.getStatus().intValue() == 5)
      {
        printinfo = new WorkflowFilePrintInfo();
        printinfo.setApplyUser(this.userManager.getUser(userLogin.getId()));
        printinfo.setWorkflowFileinbox(workflowFileinbox);
        printinfo.setSolveUser(this.userManager
          .getUser(Integer.valueOf(Integer.parseInt(applyuserid))));
        printinfo.setApplyTime(DateUtil.getDate());
        printinfo.setStatus(Integer.valueOf(2));
      }
      else
      {
        printinfo.setStatus(Integer.valueOf(2));
        printinfo.setApplyTime(DateUtil.getDate());
        printinfo.setSolveUser(this.userManager
          .getUser(Integer.valueOf(Integer.parseInt(applyuserid))));
      }
    }
    else
    {
      printinfo = new WorkflowFilePrintInfo();
      printinfo.setApplyUser(this.userManager.getUser(userLogin.getId()));
      printinfo.setWorkflowFileinbox(workflowFileinbox);
      printinfo.setSolveUser(this.userManager
        .getUser(Integer.valueOf(Integer.parseInt(applyuserid))));
      printinfo.setApplyTime(DateUtil.getDate());
      printinfo.setStatus(Integer.valueOf(2));
    }
    this.workflowFilePrintInfoManager.saveWorkflowFilePrintInfo(printinfo);
    
    Messages messages = new Messages();
    
    String title = printinfo.getWorkflowFileinbox().getWorkflowFile().getTitle();
    String content = printinfo.getApplyUser().getName();
    String url = "../../modules/workflow/workflowFilePrintInfo.do?method=list";
    Integer sourceId = Integer.valueOf(3);
    if (printinfo.getWorkflowFileinbox().getWorkflow().getCatalogy().equals("费用报销"))
    {
      title = title + "文件有打印申请,来自[费用报销]";
      content = content + "对报销单[" + printinfo.getWorkflowFileinbox().getWorkflowFile().getTitle() + "]申请打印，请处理！";
      url = "../../modules/workflow/workflowFilePrintInfo.do?method=list";
      sourceId = Integer.valueOf(63);
    }
    else
    {
      title = title + "文件有打印申请,来自[公文处理]";
      content = content + "对报销单[" + printinfo.getWorkflowFileinbox().getWorkflowFile().getTitle() + "]申请打印，请处理！";
    }
    messages.setTitle(title);
    messages.setCreatedate(DateUtil.getDate());
    
    messages.setContent(content);
    messages.setFromId(Integer.valueOf(0));
    messages.setIsread(Integer.valueOf(0));
    messages.setSourceId(sourceId);
    messages.setType(Integer.valueOf(1));
    messages.setPri(Integer.valueOf(2));
    messages.setUserByUserId(printinfo.getSolveUser());
    messages.setUserByFromuserId(printinfo.getApplyUser());
    messages.setAttachs("");
    messages.setUrl(url);
    messages.setEntityId(printinfo.getId());
    messages.setEntityClass(printinfo.getClass().getName());
    this.messagesManager.saveMessages(messages, 0);
    if (request.getParameter("type").equals("edit")) {
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
        id);
    } else {
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=show&id=" + 
        id);
    }
    return mav;
  }
  
  protected void onShow(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    String message = request.getParameter("message");
    
    String flag = request.getParameter("flag");
    









    String webIMIsIframe = request.getParameter("webIMIsIframe");
    mav.addObject("webIMIsIframe", webIMIsIframe);
    






    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
    

    UserSession userSession = getUserSession(request);
    

    mav.addObject("isHaveDocexPerm", Boolean.valueOf(this.docexFileManager.isHaveDocexPerm(this.userManager.getUser(userSession.getId()))));
    mav.addObject("isHaveBulletinAdd", Boolean.valueOf((AuthUtils.isAuthorized("AUTH_MODULES_BULLETIN_ADD")) || (AuthUtils.isAuthorized("AUTH_MODULES_BULLETIN_ADMIN"))));
    if ((workflowFileinbox == null) || ((!this.workflowManager.getIsObservers(workflowFileinbox.getWorkflow().getId(), userSession)) && 
      (!this.workflowManager.getIsSupervisor(workflowFileinbox.getWorkflow().getId(), userSession)) && 
      (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(userSession, String.valueOf(id))))) {
      createPermException(request, "协同审批->待办公文->流程信息", null);
    }
    int isSent = workflowFileinbox.getIssent().intValue();
    if ((flag != null) && (flag.equals("1")) && (
      (isSent == 2) || (isSent == 4)))
    {
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + id);
    }
    else
    {
      if ((message != null) && (!StringUtils.isBlank(message))) {
        saveMessage(request, message);
      }
      onShow(request, response, mav, id);
    }
  }
  
  protected void onShow(HttpServletRequest request, HttpServletResponse response, ModelAndView mav, Integer id)
    throws Exception
  {
    Map map = new HashMap();
    map.put("id_i_eq", String.valueOf(id));
    List workflowFileinboxList = this.workflowFileinboxManager
      .findWorkflowFileinbox(map);
    if (workflowFileinboxList.size() > 0)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)workflowFileinboxList.get(0);
      if (workflowFileinbox.getIsspecial().intValue() == 2)
      {
        Integer formId = workflowFileinbox.getFromId();
        if ((formId != null) && (formId.intValue() > 0) && ((workflowFileinbox.getIssent().intValue() == 1) || (workflowFileinbox.getIssent().intValue() == 2)))
        {
          WorkflowFileprocess workflowFileprocess = this.workflowFileinboxManager.getProcessInInbox(workflowFileinbox.getId(), formId);
          if (workflowFileprocess != null)
          {
            String username = workflowFileprocess.getUserByUserPid().getName();
            mav.addObject("username", username);
          }
        }
      }
      this.workflowFileinboxManager.convertWorkflowFile(
        workflowFileinbox.getWorkflowFile(), workflowFileinbox);
      


      WorkflowFile file = workflowFileinbox.getWorkflowFile();
      WorkFlowUtil.removeEmptyFile(file);
      
      mav.addObject("workflowFile", file);
      





















      Map<String, String> condition = new HashMap();
      condition.put("workflowFileXXid_i_eq", 
        String.valueOf(workflowFileinbox.getWorkflowFile().getId()));
      condition.put("issent_i_in", "1,2,3,13,4");
      Map order = new HashMap();
      order.put("id", "asc");
      List<WorkflowFileinbox> inboxList = this.workflowFileinboxManager
        .findWorkflowFileinbox(condition, order);
      Map<Integer, WorkflowStep> linkMap = new LinkedHashMap();
      for (WorkflowFileinbox box : inboxList) {
        linkMap.put(box.getWorkflowStep().getId(), 
          box.getWorkflowStep());
      }
      List<String> stepInfoList = new ArrayList();
      Object set = linkMap.keySet();
      String stepName = "";
      StringBuffer sb = null;
      for (Integer stepId : (Set<Integer>)set)
      {
        sb = new StringBuffer();
        for (WorkflowFileinbox box : inboxList) {
          if (stepId.intValue() == 
            box.getWorkflowStep().getId().intValue())
          {
            stepName = box.getWorkflowStep().getName();
            
            String html = "";
            if (box.getIssent().intValue() == 1) {
              html = 
                "<font color='#FF00FF'>" + box.getUser().getName() + "</font>";
            } else if ((box.getIssent().intValue() == 2) || (box.getIssent().intValue() == 4)) {
              html = 
                "<font color='#2BBF50'>" + box.getUser().getName() + "</font>";
            } else if (box.getIssent().intValue() == 3) {
              html = 
                "<font color='#333333'>" + box.getUser().getName() + "</font>";
            } else if (box.getIssent().intValue() == 13) {
              html = 
                "<font color='#333333'>" + box.getUser().getName() + "</font>";
            }
            sb.append(html).append("、");
          }
        }
        if (sb.length() > 0) {
          sb.deleteCharAt(sb.length() - 1);
        }
        String pos = String.valueOf(((WorkflowStep)linkMap.get(stepId)).getPosy()) + 
          "," + String.valueOf(((WorkflowStep)linkMap.get(stepId)).getPosx());
        stepInfoList.add(pos + "," + stepName + "," + sb.toString());
      }
      Collections.sort(stepInfoList, new Comparator()
      {
        public int compare(Object arg0, Object arg1) 
        {
        	String o1=arg0.toString();
        	String o2=arg1.toString();
          int a = Integer.parseInt(o1.split(",")[0]);
          int b = Integer.parseInt(o2.split(",")[0]);
          int c = Integer.parseInt(o1.split(",")[1]);
          int d = Integer.parseInt(o2.split(",")[1]);
          if (a - b != 0) {
            return a - b;
          }
          return c - d;
        }
      });
      mav.addObject("allStepInfo", stepInfoList);
      mav.addObject("currentFileinboxes", 
        this.workflowFileinboxManager
        .findCurrentFileinbox(workflowFileinbox.getWorkflowFile().getId()));
      



















































      mav.addObject("wordprintAttachs", this.workflowFileManager.showWordPrintAttach(request, workflowFileinbox.getWorkflowFile()));
      















      mav.addObject("workflowFileinbox", workflowFileinbox);
      if ((workflowFileinbox.getIssent().intValue() == 1) || 
        (workflowFileinbox.getIssent().intValue() == 2))
      {
        Date nowDate = new Date();
        if ((workflowFileinbox.getWorkflowStep().getDays() != null) && 
          (workflowFileinbox.getWorkflowStep().getDays().intValue() != 0))
        {
          int internal = workflowFileinbox.getWorkflowStep()
            .getDays().intValue() * 60;
          
          Date termDate = this.systemWorkhourManager.getBusinessTime(
            workflowFileinbox.getUser(), 
            workflowFileinbox.getStartdate(), Integer.valueOf(internal));
          if (nowDate.compareTo(termDate) > 0) {
            saveMessage(request, 
            
              getMessage(request, "WorkflowFileinboxManagerController_label60", "该文件已超过办理期限，请抓紧时间办理！"));
          }
        }
        else if ((workflowFileinbox.getWishdate() != null) && 
          (nowDate.compareTo(workflowFileinbox.getWishdate()) > 0))
        {
          saveMessage(request, 
          
            getMessage(request, "WorkflowFileinboxManagerController_label60", "该文件已超过办理期限，请抓紧时间办理！"));
        }
      }
      if ("".equals(this.workflowFlowtypeManager
        .getWorkflowTemplate(workflowFileinbox.getWorkflowFile(), ""))) {
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label22", "模板文件不存在，请联系系统管理员！"));
      }
      String content = this.workflowFlowtypeManager
        .getWorkflowTemplateContent(workflowFileinbox
        .getWorkflowFile(), "");
      
      Pattern pattern = Pattern.compile("(<textarea.*?>)(.*?)(</textarea>)", 32);
      Matcher matcher = pattern.matcher(content);
      StringBuffer buffer = new StringBuffer();
      while (matcher.find()) {
        matcher.appendReplacement(buffer, "$1$3");
      }
      matcher.appendTail(buffer);
      content = buffer.toString();
      
      UserSession user = (UserSession)request.getSession().getAttribute(
        org.springside.core.Constants.USER_IN_SESSION);
      
      mav.addObject("dynamicForm", 
        this.workflowFlowtypeManager.getDynamicForm(workflowFileinbox, true, user, content));
      

      mav.addObject("currentSents", this.workflowFileinboxManager.getCurrentSent2(workflowFileinbox));
      
      mav.addObject("canPrint", 
      
        Integer.valueOf(this.workflowFlowtypeManager.existWorkflowTemplate(workflowFileinbox.getWorkflowFile(), "print")));
      

      mav.addObject("nextStepInboxs", this.workflowFileinboxManager.getNextStepFileinbox2(workflowFileinbox));
      if ((workflowFileinbox.getWorkflowFile().getFromId() != null) && 
        (workflowFileinbox.getWorkflowFile().getFromId().intValue() != 0))
      {
        if (workflowFileinbox.getWorkflowFile().getFromType().intValue() < 3)
        {
          WorkflowFile wf = null;
          try
          {
            wf = this.workflowFileManager.getWorkflowFile(workflowFileinbox.getWorkflowFile().getFromId());
          }
          catch (Exception e)
          {
            saveMessage(request, 
              getMessage(request, "注意:此文件的参考公文不存在或已经被删除！", "注意:此文件的参考公文不存在或已经被删除！"));
            this.logger.info("关联公文已被删除！");
          }
          if (wf != null) {
            mav.addObject("relationFile", wf);
          }
        }
        mav.addObject("relationFileId", StrUtils.getEncString(
          workflowFileinbox.getWorkflowFile().getFromId().toString()));
      }
      if ((workflowFileinbox.getLeaveword() != null) && 
        (!"".equals(workflowFileinbox.getLeaveword()))) {
        saveMessage(request, workflowFileinbox.getLeaveword());
      }
      int canCheckin = this.workflowFileinboxManager
        .getCanCheckin(workflowFileinbox);
      if ((workflowFileinbox.getWorkflowStep().getLogictype() != null) && 
        (workflowFileinbox.getWorkflowStep().getLogictype()
        .intValue() == 4) && (canCheckin == 0)) {
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label24", "此节点为顺序审批节点，需要等待前面用户处理完成后再进行处理！"));
      }
      mav.addObject("canCheckin", Integer.valueOf(canCheckin));
      //====================2015-01-20=============================
    //2014-01-04 办结文件可修改且保存状态。 begin
		if ("FIRSTHXSM".equalsIgnoreCase(org.springside.core.Constants.PROJECT_NAME)) {
			Map filter3 = new HashMap();
			filter3.put("workflowFileinboxXXid_i_eq",
					workflowFileinbox.getId());
			List chanagelist = this.workflowFileChangeManager.findWorkflowFileChange(filter3);
			String message = "";
			if ((chanagelist != null) && (chanagelist.size() > 0)) {
				boolean flag = true;
				for (int i = 0; i < chanagelist.size(); i++) {
					WorkflowFileChange chanageinfo = (WorkflowFileChange) chanagelist.get(i);
					if (chanageinfo.getStatus().intValue() != 5) {
						flag = false;
						if (chanageinfo.getStatus().intValue() == 4) {
							message = "你申请的文件变更已经被同意了!";
						}
						else if (chanageinfo.getStatus().intValue() == 2) {
							message = "此文件正在申请文件变更！";
						}
						else if (chanageinfo.getStatus().intValue() == 3) {
							message = "此文件变更申请被拒绝！";
						}
						mav.addObject("workflowFileChange", chanageinfo);
						mav.addObject("changeInfo", message);
						break;
					}
				}
				if (flag) {
					WorkflowFileChange chanageinfo = (WorkflowFileChange) chanagelist.get(chanagelist.size() - 1);
					message = "此文件已经变更处理过！";
					mav.addObject("changeInfo", message);
					mav.addObject("workflowFileChange", chanageinfo);
				}
			}
		   //2014-01-04 办结文件可修改且保存状态。end
		}
      //===========================================================
      
      if ("FIRSTHXSM".equalsIgnoreCase(org.springside.core.Constants.PROJECT_NAME))
      {
        Map filter = new HashMap();
        UserSession userLogin = (UserSession)request.getSession()
          .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
        
        filter.put("workflowFileinboxXXid_i_eq", 
          workflowFileinbox.getId());
        List printlist = this.workflowFilePrintInfoManager
          .findWorkflowFilePrintInfo(filter);
        String message = "";
        if ((printlist != null) && (printlist.size()==1))
        {
          WorkflowFilePrintInfo printinfo = 
            (WorkflowFilePrintInfo)printlist.get(0);
          mav.addObject("workflowFilePrintInfo", printinfo);
          if (printinfo.getStatus() != null)
          {
            if (printinfo.getStatus().intValue() == 4) {
              message = "你的申请已经被同意了";
            }
            else if (printinfo.getStatus().intValue() == 5) {
              message = "此文件已经被打印";
            }
            else if (printinfo.getStatus().intValue() == 2) {
              message = "此文件正在申请打印中";
            }
            else if (printinfo.getStatus().intValue() == 3) {
              message = "此文件打印申请被拒绝！";
            }
            mav.addObject("printInfo", message);
          }
        }
        else if (printlist.size() >= 2)
        {
        	boolean flag=true;
          for (int i = 0; i < printlist.size(); i++)
          {
            WorkflowFilePrintInfo printinfo = 
              (WorkflowFilePrintInfo)printlist.get(i);
            if (printinfo.getStatus().intValue() != 5)
            {
            	flag=false;
              if (printinfo.getStatus().intValue() == 4) {
                message = "你的申请已经被同意了";
              }
              else if (printinfo.getStatus().intValue() == 2) {
                message = "此文件正在申请打印中";
              }
              else if (printinfo.getStatus().intValue() == 3) {
                message = "此文件打印申请被拒绝！";
              }
              mav.addObject("workflowFilePrintInfo", printinfo);
              mav.addObject("printInfo", message);
              break;
            }
          }
          if(flag){
        	  WorkflowFilePrintInfo printinfo = (WorkflowFilePrintInfo)printlist.get(printlist.size()-1);
        	  message = "此文件已经被打印";
        	  mav.addObject("printInfo", message);
        	  mav.addObject("workflowFilePrintInfo", printinfo);
          }
        }
        String userid = workflowFileinbox.getWorkflow()
          .getSuperprinters();
        if ((userid != null) && (!userid.equals("")))
        {
          Map filter1 = new HashMap();
          filter1.put("id_i_in", userid);
          mav.addObject("applyUsers", this.userManager.findUser(filter1));
        }
      }
      Set<User> attentionUsers = workflowFileinbox.getWorkflowFile()
        .getAttentionUsers();
      if (attentionUsers.contains(this.userManager.getUser(user.getId()))) {
        mav.addObject("attention", "true");
      }
      mav.addObject("printtemplates", 
        this.workflowFlowtypeManager
        .findWordtemplateByType(workflowFileinbox.getWorkflow().getFlowtypeId(), Integer.valueOf(3)));
      

      String allActions = this.workflowStepManager.getAllWorkflowStepActionsByUser(workflowFileinbox, getUserSession(request));
      mav.addObject("allActions", allActions);
      

      mav.addObject("knowledgesList", this.workflowKnowledgeManager.getWorkflowKnowledgeList(workflowFileinbox.getWorkflow().getId()));
    }
    else
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
    }
  }
  
  public ModelAndView print(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    
    Map map = new HashMap();
    map.put("id_i_eq", String.valueOf(id));
    List workflowFileinboxList = this.workflowFileinboxManager
      .findWorkflowFileinbox(map);
    if (workflowFileinboxList.size() > 0)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)workflowFileinboxList.get(0);
      
























      this.workflowFileinboxManager.convertWorkflowFile(
        workflowFileinbox.getWorkflowFile(), workflowFileinbox);
      
































      String fileFormat = request.getParameter("fileFormat");
      if ((fileFormat == null) || ("".equals(fileFormat)) || 
        ("html".equalsIgnoreCase(fileFormat)) || 
        ("htm".equalsIgnoreCase(fileFormat)))
      {
        String originalPrintForm = null;
        String strPrinttemplateId = request
          .getParameter("printtemplateId");
        if ((strPrinttemplateId == null) || 
          (strPrinttemplateId.trim().equals("")))
        {
          originalPrintForm = 
            this.workflowFlowtypeManager.getWorkflowTemplate(workflowFileinbox
            .getWorkflowFile(), "print");
        }
        else
        {
          Integer wordTemplateId = new Integer(strPrinttemplateId);
          WorkflowWordtemplate workflowWordtemplate = this.workflowFlowtypeManager
            .getWorkflowWordtemplate(wordTemplateId);
          String serverfile = workflowWordtemplate.getServerfile();
          if (StorageUtil.exists(serverfile)) {
            originalPrintForm = StorageUtil.readFile(serverfile);
          } else {
            saveMessage(request, 
            
              getMessage(request, "WorkflowFileinboxManagerController_label22", "模板文件不存在，请联系系统管理员！"));
          }
        }
        String printForm = this.workflowFlowtypeManager.getPrintForm(
          workflowFileinbox, originalPrintForm);
        if (printForm != null)
        {
          printForm = printForm.replaceAll("｛打印人｝", 
            workflowFileinbox.getUser().getName());
          
          String printDateStr = DateUtil.getToday();
          printForm = printForm.replaceAll("｛打印日期｝", printDateStr);
          int death = 0;
          for (;;)
          {
            death++;
            if (death > 20) {
              break;
            }
            int fstart = printForm.indexOf("｛打印日期｜");
            if (fstart < 0) {
              break;
            }
            int fend = printForm.indexOf("｝", fstart);
            if (fend < 0) {
              break;
            }
            String fstr = printForm.substring(fstart, 
              fend + 1);
            
            String formatStr = fstr.substring(
              fstr.lastIndexOf("｜") + 1, fstr
              .lastIndexOf("｝"));
            try
            {
              printDateStr = DateUtil.format(
                DateUtil.getDate(), formatStr);
            }
            catch (Exception e)
            {
              this.logger.info(fstr + 
                "，打印日期格式设置不正确，使用默认格式打印输出！");
            }
            printForm = printForm.replaceAll(fstr, 
              printDateStr);
          }
        }
        String url = "http://" + request.getServerName() + ":" + 
          request.getServerPort() + request.getContextPath() + 
          "/modules/setting/workflowSignature.do";
        
        printForm = printForm.replaceAll(
          "../../modules/setting/workflowSignature.do", url);
        






















        response.setContentType("application/msword; charset=GBK");
        


        String filename = workflowFileinbox.getWorkflowFile()
          .getTitle().replaceAll("[\n\r]", " ") + 
          "." + org.springside.core.Constants.WORKFLOW_PRINT_FORMAT;
        
        response.setHeader("Content-Disposition", 
          "attachment; filename=" + 
          new String(filename.getBytes("GBK"), 
          "ISO-8859-1"));
        response.getWriter().write(printForm);
      }
      else if ("doc".equalsIgnoreCase(fileFormat))
      {
        printWord(request, response);
      }
    }
    else
    {
      response.setContentType("application/msword; charset=GBK");
      
      response.setHeader("Content-Disposition", "attachment; filename=" + 
        new String("wordPrint".getBytes("GBK"), "ISO-8859-1"));
      response.getWriter().write(
        getMessage(request, 
        "WorkflowFileinboxManagerController_label25", 
        "此节点文件可能被取回或者被其他人删除!"));
    }
    return null;
  }
  
  public ModelAndView goToPrint(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView(
      "/modules/workflow/workflowFileattach_wordprint2.jsp");
    Integer id = new Integer(request.getParameter("fileinboxId"));
    WorkflowFileinbox workflowFileinbox = null;
    try
    {
      workflowFileinbox = 
        this.workflowFileinboxManager.getWorkflowFileinbox(id);
    }
    catch (Exception e)
    {
      this.logger.error(e);
    }
    if (workflowFileinbox == null)
    {
      mav.addObject("isDeleted", "yes");
      return mav;
    }
    workflowFileinbox.getWorkflowFile().setTitle(workflowFileinbox.getWorkflowFile().getTitle().replaceAll("\\n", "").replaceAll("\\t", "").replaceAll("\\r", ""));
    
    mav.addObject("workflowFileinbox", workflowFileinbox);
    if (workflowFileinbox.getWorkflowFile().getPriority() != null)
    {
      String myValue = 
        (String)org.springside.core.Constants.WORKFLOW_PRIORITY_MAP.get(workflowFileinbox.getWorkflowFile().getPriority());
      if (myValue == null) {
        myValue = "";
      }
      if (myValue.startsWith("!")) {
        myValue = myValue.substring(1);
      }
      mav.addObject("priority", myValue);
    }
    else
    {
      mav.addObject("priority", "");
    }
    List<WorkflowFlowfield> list = this.workflowFlowfieldManager
      .findAllWorkflowFlowfieldByFlwotypeId(workflowFileinbox
      .getWorkflow().getFlowtypeId());
    
    Map<Integer, Integer> shortListMap = new HashMap();
    Map<Integer, Integer> longListMap = new HashMap();
    
    this.workflowFlowtypeManager.getFieldListMap(workflowFileinbox.getWorkflowFile(), shortListMap, longListMap);
    for (WorkflowFlowfield workflowFlowfield : list) {
      if (workflowFlowfield.getFieldtype().equals("list")) {
        workflowFlowfield.setFieldserial(Integer.valueOf(this.workflowFlowtypeManager.getIndex(workflowFlowfield, shortListMap, longListMap)));
      }
    }
    mav.addObject("workflowFlowfields", list);
    return mav;
  }
  
  public ModelAndView printWord(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    Map map = new HashMap();
    map.put("id_i_eq", String.valueOf(id));
    List workflowFileinboxList = this.workflowFileinboxManager
      .findWorkflowFileinbox(map);
    if (workflowFileinboxList.size() > 0)
    {
      WorkflowFileinbox workflowFileinbox = 
        (WorkflowFileinbox)workflowFileinboxList.get(0);
      

      String originalPrintForm = null;
      String strPrinttemplateId = request.getParameter("printtemplateId");
      if ((strPrinttemplateId == null) || 
        (strPrinttemplateId.trim().equals("")))
      {
        defaultPrint(request, response, workflowFileinbox);
      }
      else
      {
        Integer wordTemplateId = new Integer(strPrinttemplateId);
        WorkflowWordtemplate workflowWordtemplate = this.workflowFlowtypeManager
          .getWorkflowWordtemplate(wordTemplateId);
        String serverfile = workflowWordtemplate.getServerfile();
        if (StorageUtil.exists(serverfile))
        {
          response.setContentType(workflowWordtemplate.getFileext());
          
          response.setContentLength(new Integer(
            String.valueOf(StorageUtil.getSize(serverfile))).intValue());
          
          response.setHeader("Content-Disposition", 
            "attachment; filename=" + 
            new String(
            workflowWordtemplate.getFilename().getBytes("GBK"), 
            "ISO-8859-1"));
          
          StorageUtil.download(serverfile, response.getOutputStream());
        }
        else
        {
          saveMessage(request, 
          
            getMessage(request, "WorkflowFileinboxManagerController_label22", "模板文件不存在，请联系系统管理员！"));
        }
      }
    }
    else
    {
      response.setContentType("application/msword; charset=GBK");
      
      response.setHeader("Content-Disposition", "attachment; filename=" + 
        new String("wordPrint".getBytes("GBK"), "ISO-8859-1"));
      response.getWriter().write(
        getMessage(request, 
        "WorkflowFileinboxManagerController_label25", 
        "此节点文件可能被取回或者被其他人删除!"));
    }
    return null;
  }
  
  private void defaultPrint(HttpServletRequest request, HttpServletResponse response, WorkflowFileinbox workflowFileinbox)
    throws BusinessException, UnsupportedEncodingException, IOException
  {
    String originalPrintForm = this.workflowFlowtypeManager.getWorkflowTemplate(
      workflowFileinbox.getWorkflowFile(), "print");
    String printForm = this.workflowFlowtypeManager.getPrintForm(
      workflowFileinbox, originalPrintForm);
    if (printForm != null)
    {
      printForm = printForm.replaceAll("｛打印人｝", 
        workflowFileinbox.getUser().getName());
      
      String printDateStr = DateUtil.getToday();
      printForm = printForm.replaceAll("｛打印日期｝", printDateStr);
      int death = 0;
      for (;;)
      {
        death++;
        if (death > 20) {
          break;
        }
        int fstart = printForm.indexOf("｛打印日期｜");
        if (fstart < 0) {
          break;
        }
        int fend = printForm.indexOf("｝", fstart);
        if (fend < 0) {
          break;
        }
        String fstr = printForm.substring(fstart, fend + 1);
        String formatStr = fstr.substring(
          fstr.lastIndexOf("｜") + 1, 
          fstr.lastIndexOf("｝"));
        try
        {
          printDateStr = DateUtil.format(DateUtil.getDate(), 
            formatStr);
        }
        catch (Exception e)
        {
          this.logger.info(fstr + "，打印日期格式设置不正确，使用默认格式打印输出！");
        }
        printForm = printForm.replaceAll(fstr, printDateStr);
      }
    }
    String url = "http://" + request.getServerName() + ":" + 
      request.getServerPort() + request.getContextPath() + 
      "/modules/setting/workflowSignature.do";
    printForm = printForm.replaceAll(
      "../../modules/setting/workflowSignature.do", url);
    





















    response.setContentType("application/msword; charset=GBK");
    String filename = workflowFileinbox.getWorkflowFile().getTitle()
      .replaceAll("[\n\r]", " ") + 
      "." + org.springside.core.Constants.WORKFLOW_PRINT_FORMAT;
    response.setHeader("Content-Disposition", "attachment; filename=" + 
      new String(filename.getBytes("GBK"), "ISO-8859-1"));
    response.getWriter().write(printForm);
  }
  
  protected void referenceData(HttpServletRequest request, Map model)
  {
    model.put("now", DateUtil.getDate());
  }
  
  public ModelAndView save(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=");
    
    onSave(request, response, mav, true, true);
    
    return mav;
  }
  
  public ModelAndView update(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=");
    
    onSave(request, response, mav, false, true);
    


    String from = request.getParameter("from");
    if ((from != null) && (!"".equals(from))) {
      mav.setViewName(mav.getViewName() + "&from=" + from);
    }
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    String viewName = UrlUtil.getUrlParams(mav.getViewName(), map, "search_") + "&searchId=" + request.getParameter("searchId");
    mav.setViewName(viewName);
    return mav;
  }
  
  protected void onSave(HttpServletRequest request, HttpServletResponse response, ModelAndView mav, boolean isNew, boolean isRedirect)
    throws Exception
  {
    String returnView = "";
    String anchor = "";
    
    String inboxIdStr = request.getParameter("inboxId");
    String flowIdStr = request.getParameter("flowId");

    UserSession userSession = getUserSession(request);
    





    Integer inboxId = Integer.valueOf(0);
    if ((inboxIdStr == null) || ("".equals(inboxIdStr.trim()))) {
      isNew = true;
    } else {
      inboxId = Integer.valueOf(Integer.parseInt(inboxIdStr));
    }
    

    //2015-01-20
    String  type="1";//默认支持通过 ，现支持 1:通用，2：专案，3；市场费用
    String  fieldstr1="";
    if (!isNew)
    {
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(inboxId);
      
      fieldstr1=workflowFileinbox.getWorkflowFile().getFieldstr1();
      String flowtype=workflowFileinbox.getWorkflowFile().getWorkflowFlowtype().getId().toString();
      //20161026 烘陪tp2季度，定量装tp2季度，散装tp2季度。
      if(flowtype.equals("47")||flowtype.equals("53")||flowtype.equals("55")||flowtype.equals("56")||flowtype.equals("99")||flowtype.equals("100")||flowtype.equals("101")){
    	  //TP2年度签呈,TP2季度,进场年度，红字年度   多月逻辑处理
    	  type="2";
      }else if(flowtype.equals("35") || flowtype.equals("36") || flowtype.equals("37")){
    	  //市场费用同步发货通知单
    	  type="3";
      }
      
      if (!StringUtils.isBlank(workflowFileinbox.getWorkflowFile().getEndDesc()))
      {
        endFlowMessage(workflowFileinbox.getWorkflowFile(), request);
        mav.setViewName(this.successView);
        return;
      }
    }
    if ((!StringUtils.isBlank(flowIdStr)) && (StringUtils.isBlank(inboxIdStr)))
    {
      if (!this.workflowManager.getCanOperate(Integer.valueOf(flowIdStr), userSession)) {
        createPermException(request, "协同审批->新建公文->暂存", null);
      }
    }else{
        //2014-01-03 变更办结可修改处理 begin
    	
		Map filter3 = new HashMap();
		filter3.put("workflowFileinboxXXid_i_eq",inboxId);
		filter3.put("status_i_eq",4);
		List chanagelist = this.workflowFileChangeManager.findWorkflowFileChange(filter3);
		if(chanagelist!=null && chanagelist.size()>0){
			//修改文件变更记录
			WorkflowFileChange workflowFileChange=(WorkflowFileChange)chanagelist.get(0);
			workflowFileChange.setStatus(Integer.valueOf(5));
   			workflowFileChange.setPrintTime(DateUtil.getDate());
			workflowFileChangeManager.saveWorkflowFileChange(workflowFileChange);
			//=====2014-01-04 begin保存数据同时需删除同步费用预算单信息
			int k3delete=workflowFileChangeManager.deleteK3WorkflowFile(fieldstr1, type);
			if(k3delete==0){
				createPermException(request, "协同审批->待办公文->暂存", "由于K3单据已经审核不能变更处理，请联系财务确认!");
			}
			//=====2014-01-04 end 保存数据同时需删除同步费用预算单信息
		}else if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, inboxIdStr)) {
		    createPermException(request, "协同审批->待办公文->暂存", null);
		}
    }
    User user = this.userManager.getUser(userSession.getId());
    WorkflowFileinbox workflowFileinbox = null;

    String isNewFlag = request.getParameter("isNew");
    if ((isNewFlag != null) && ("true".equals(isNewFlag))) {
      isNew = true;
    }
    String isUpload = request.getParameter("isUpload");
    String opinionStr;
    if (isNew)
    {
      Integer flowId = new Integer(request.getParameter("flowId"));
      workflowFileinbox = this.workflowFileinboxManager.init(flowId,  userSession);
      this.workflowFileinboxManager.autoGenerteMobileForm(workflowFileinbox);
      if (workflowFileinbox.getWorkflow().getEditStyle().intValue() == 0) {
        returnView = this.editView;
      } else {
        returnView = "/modules/workflow/workflowFileinbox_edit_mulit.jsp";
      }
      returnView = 
        returnView + "?method=create&flowId=" + String.valueOf(flowId);
    }
    else
    {
      try
      {
        workflowFileinbox = 
          this.workflowFileinboxManager.getWorkflowFileinbox(inboxId);
        if (workflowFileinbox.getWorkflowFile().getFlowFlag().intValue() == 5)
        {
          saveNullifyMessage(workflowFileinbox.getWorkflowFile(), request);
          mav.setViewName(this.successView);
          return;
        }
        if (!StringUtils.isBlank(workflowFileinbox.getWorkflowFile().getEndDesc()))
        {
          endFlowMessage(workflowFileinbox.getWorkflowFile(), request);
          mav.setViewName(this.successView);
          return;
        }
        if (workflowFileinbox.getWorkflow().getEditStyle().intValue() == 0) {
          returnView = this.editView;
        } else {
          returnView = "/modules/workflow/workflowFileinbox_edit_mulit.jsp";
        }
        returnView = 
          returnView + "?method=edit&inboxId=" + String.valueOf(inboxId);
        

        String command = request.getParameter("command");
        if ("saveOpinionx".equals(command))
        {
          String optionvalue = request.getParameter("optionvalue");
          String[] ov = optionvalue.split("!,,!");
          
          WorkflowShortopinion workflowShortopinion = this.workflowShortopinionManager
            .getWorkflowShortopinion(new Integer(ov[1]));
          this.workflowFileinboxManager.saveOpinion(workflowFileinbox, 
            workflowShortopinion.getName(), ov[0]);
          anchor = ov[0] + "_anchor";
        }
        else if ("saveOpinion".equals(command))
        {
          String optionvalue = request.getParameter("optionvalue");
          String[] ov = optionvalue.split("!,,!");
          this.workflowFileinboxManager.saveOpinion(workflowFileinbox, 
            ov[1], ov[0]);
          anchor = ov[0] + "_anchor";
        }
        else if ("saveSign".equals(command))
        {
          String optionvalue = request.getParameter("optionvalue");
          String[] ov = optionvalue.split("!,,!");
          anchor = ov[0] + "_anchor";
        }
        Map ajaxopinionMap = WebUtils.getParametersStartingWith(
          request, "ajaxopinion_");
        
        Set keys1 = ajaxopinionMap.keySet();
        for (Object key : keys1)
        {
          String myKey = (String)key;
          String value = String.valueOf(ajaxopinionMap.get(myKey));
          opinionStr = request.getParameter(myKey);
          String blankOpinion = ServletRequestUtils.getStringParameter(request, 
            "blankOpinion", "");
          if (opinionStr == null) {
            opinionStr = "";
          }
          this.logger.info(opinionStr + "  ---  " + blankOpinion);
          if (opinionStr.equals(blankOpinion)) {
            opinionStr = "";
          }
          if (("1".equals(value)) && (!"".equals(opinionStr))) {
            this.workflowFileinboxManager.saveAjaxOpinion(
              workflowFileinbox, opinionStr, myKey
              .replace("str", ""));
          }
        }
        this.workflowFileinboxManager.saveUpdateStatus(workflowFileinbox);
      }
      catch (Exception e)
      {
        mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
        mav.addObject("isSuccess", Integer.valueOf(1));
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
        return;
      }
    }
    BindingResult result = bindObject(request, 
      workflowFileinbox.getWorkflowFile());
    



    String atitle = workflowFileinbox.getWorkflowFile().getTitle();
    atitle = StringUtils.isEmpty(atitle) ? "" : atitle;
    



    workflowFileinbox.getWorkflowFile().setTitle(atitle);
    if (result.hasErrors())
    {
      onBindError(request, result, mav, returnView);
      return;
    }
    if ((workflowFileinbox.getIssent().intValue() == 9) || (workflowFileinbox.getIssent().intValue() == 2))
    {
      String deptId = request.getParameter("deptId");
      if ((deptId != null) && (!"".equals(deptId))) {
        workflowFileinbox.getWorkflowFile().setDept(
          this.deptManager.getDept(new Integer(deptId)));
      }
    }
    Map listMap = WebUtils.getParametersStartingWith(request, "listZZ");
    
    Map detailMap = 
      WebUtils.getParametersStartingWith(request, "detailstr");
    
    Map singleopinionMap = WebUtils.getParametersStartingWith(request, 
      "singleopinion_");
    
    Set keys = singleopinionMap.keySet();
    for (Object key : keys)
    {
      String myKey = (String)key;
      String value = String.valueOf(singleopinionMap.get(myKey));
      

      String defaultValue = ServletRequestUtils.getStringParameter(request, myKey, "");
      


      Map<String, String> filter = new HashMap();
      filter.put("fileId_i_eq", String.valueOf(workflowFileinbox.getWorkflowFile().getId()));
      filter.put("stepId_i_eq", String.valueOf(workflowFileinbox.getWorkflowStep().getId()));
      filter.put("signField_s_eq", myKey.replace("str", ""));
      WorkflowFileopinion opinion = this.workflowFileinboxManager.findWorkflowFileopinion(filter);
      if (("1".equals(value)) || ((!"".equals(defaultValue)) && (opinion == null)))
      {
        String opinionStr1 = request.getParameter(myKey);
        if (opinionStr1 == null) {
        	opinionStr1 = "";
        }
        this.workflowFileinboxManager.saveSingleOpinion(workflowFileinbox, 
        		opinionStr1, myKey.replace("str", ""));
      }
    }
    this.workflowFileinboxManager.convertWorkflowFilex(
      workflowFileinbox.getWorkflowFile(), listMap, detailMap);
    if ((workflowFileinbox.getWorkflowFile().getTitle() == null) || 
    
      ("".equals(workflowFileinbox.getWorkflowFile()
      .getTitle()))) {
      workflowFileinbox.getWorkflowFile().setTitle(
        workflowFileinbox.getWorkflowFile()
        .getWorkflowFlowtype().getName());
    }
    String fromType = request.getParameter("fromTypeValue");
    String fromId = request.getParameter("fromIdValue");
    if ((fromId != null) && (!"".equals(fromId))) {
      workflowFileinbox.getWorkflowFile().setFromId(Integer.valueOf(Integer.parseInt(fromId)));
    }
    if ((fromType != null) && (!"".equals(fromType))) {
      workflowFileinbox.getWorkflowFile().setFromType(Integer.valueOf(Integer.parseInt(fromType)));
    }
    this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox, isNew);
    if (isNew)
    {
      if ((!"yes".equals(isUpload)) && (!"onlineCreate".equals(isUpload)) && 
        (!ServletRequestUtils.getBooleanParameter(request, "isNew", false))) {
        saveMessage(
          request, 
          getMessage(
          request, 
          "WorkflowFileinboxManagerController_label26", 
          "表单保存成功！你可以编辑正文或上传附件！编辑正文或者上传附件前，如果表单进行了修改，请先暂存表单！"));
      }
      if ("scanSave".equals(request.getParameter("method")))
      {
        String documentDir = "/workflow/document";
        
        String filetype = request.getParameter("filetype");
        
        String filename = request.getParameter("filename");
        if ((filename == null) || ("".equals(filename))) {
          filename = getMessage(request, 
            "WorkflowFileinboxManagerController_label27", 
            "扫描文件");
        }
        String tempname = "scan_temp_" + userSession.getId() + "." + 
          filetype;
        
        String srcfile = "/workflow/temporary/" + 
          tempname;
        
        documentDir = documentDir + 
          "/" + 
          DateUtil.getYearmonth(workflowFileinbox
          .getWorkflowFile().getSubmitdate()) + 
          "/" + 
          String.valueOf(workflowFileinbox.getWorkflow()
          .getId()) + 
          "/" + 
          String.valueOf(workflowFileinbox.getWorkflowFile()
          .getId());
        String desfile = documentDir + "/" + DateUtil.getOnlyID();
        if (StorageUtil.exists(srcfile))
        {
          StorageUtil.copy(srcfile, desfile);
          WorkflowFileattach workflowFileattach = new WorkflowFileattach();
          workflowFileattach.setWorkflowFile(
            workflowFileinbox.getWorkflowFile());
          workflowFileattach.setFilename("V1_" + filename + "." + 
            filetype);
          workflowFileattach.setServerfile(desfile);
          workflowFileattach.setDescn(
          
            getMessage(request, "WorkflowFileinboxManagerController_label27", "扫描文件"));
          workflowFileattach.setCheckout(Integer.valueOf(0));
          workflowFileattach.setCreatedate(DateUtil.getDate());
          if ("pdf".equals(filetype)) {
            workflowFileattach.setFileext("application/pdf");
          } else {
            workflowFileattach.setFileext("image/tiff");
          }
          workflowFileattach.setFilesize(Integer.valueOf(Integer.parseInt(
            String.valueOf(StorageUtil.getSize(desfile)))));
          workflowFileattach.setLastver(Integer.valueOf(1));
          workflowFileattach.setTitle(filename);
          
          workflowFileattach.setType(Integer.valueOf(1));
          workflowFileattach.setUserByUserId(
            workflowFileinbox.getUser());
          workflowFileattach.setVer(Integer.valueOf(1));
          this.workflowFileattachManager.saveWorkflowFileattach(
            workflowFileattach, true);
          
          StorageUtil.delete(srcfile);
        }
      }
    }
    if (isRedirect) {
      if (!"".equals(anchor)) {
        mav.setViewName(mav.getViewName() + workflowFileinbox.getId() + 
          "&#" + anchor);
      } else {
        mav.setViewName(mav.getViewName() + workflowFileinbox.getId());
      }
    }
    String bxft = ServletRequestUtils.getStringParameter(request, "SHOW_BAOXIAOFENTAN", "no");
    if (bxft.equals("yes")) {
      if (",报销分摊开始,经营管理部审核,退回申请人,".indexOf(workflowFileinbox.getWorkflowStep().getName()) > -1)
      {
        WorkflowFile workflowFile = workflowFileinbox.getWorkflowFile();
        Map<String, String> filter = new HashMap();
        filter.put("flowtypeId_i_eq", 
          workflowFileinbox.getWorkflow().getFlowtypeId().toString());
        List<WorkflowFlowfield> fields = this.workflowFlowfieldManager
          .findWorkflowFlowfield(filter);
        



        String bxdateName = "";
        String bxlxName = "";
        String bxnrzyName = "";
        String jeName = "";
        String bzName = "";
        String hjName = "";
        String pzCountName = "";
        for (WorkflowFlowfield field : fields) {
          if ("报销类型".equals(field.getName()))
          {
            bxlxName = "fieldstr" + field.getFieldserial();
          }
          else
          {
            if (",报销内容摘要,金额,备注,".contains("," + field.getName() + 
              ",")) {
              if (field.getFieldtype().equals("list"))
              {
                String fname = "fieldstr" + field.getFieldserial() + "ZZ";
                if ("报销内容摘要".equals(field.getName()))
                {
                  bxnrzyName = fname; continue;
                }
                if ("金额".equals(field.getName()))
                {
                  jeName = fname; continue;
                }
                bzName = fname; continue;
              }
            }
            if ("合计金额".equals(field.getName())) {
              hjName = "fieldstr" + field.getFieldserial();
            } else if ("报销日期".equals(field.getName())) {
              bxdateName = "fieldstr" + field.getFieldserial();
            } else if ("凭证张数".equals(field.getName())) {
              pzCountName = "fieldstr" + field.getFieldserial();
            }
          }
        }
        PlBaoxiao plBaoxiao = null;
        if (isNew)
        {
          plBaoxiao = new PlBaoxiao();
          plBaoxiao.setWorkflowFile(workflowFile);
          plBaoxiao.setCreatedate(workflowFile.getSubmitdate());
          plBaoxiao.setDept(workflowFile.getDept());
          plBaoxiao.setUser(workflowFile.getUser());
          plBaoxiao.setBxdNo(workflowFile.getFileno());
        }
        else
        {
          plBaoxiao = this.plBaoxiaoManager.getPlBaoxiao(Integer.valueOf(ServletRequestUtils.getIntParameter(
            request, "baoxiaoid", 0)));
        }
        Object value = ReflectUtil.getClassAttributeValue(workflowFile, 
          bxdateName);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        
        plBaoxiao.setBsdate(sdf.parse((String)value));
        
        value = ReflectUtil.getClassAttributeValue(workflowFile, 
          pzCountName);
        plBaoxiao.setPzCount(
          Integer.valueOf(String.valueOf((String)value)));
        
        int bxtype_id = ServletRequestUtils.getIntParameter(request, "bxtype", 0);
        PlDicts bxtype = this.plDictsManager.getPlDicts(Integer.valueOf(bxtype_id));
        plBaoxiao.setPlDicts(bxtype);
        
        value = ReflectUtil.getClassAttributeValue(workflowFile, hjName);
        plBaoxiao.setHejiSum(Double.valueOf(Double.parseDouble(value.toString())));
        
        this.plBaoxiaoManager.savePlBaoxiao(plBaoxiao);
        



        this.jdbcTemplate.execute("delete from pl_baoxiao_mx where bx_id=" + 
          plBaoxiao.getId());
        for (int i = 1; i <= 4; i++)
        {
          String jeStr = (String)listMap.get(jeName + i);
          if (!jeStr.equals(""))
          {
            PlBaoxiaoMx plBaoxiaoMx = new PlBaoxiaoMx();
            plBaoxiaoMx.setBxSum(Double.valueOf(jeStr));
            plBaoxiaoMx
              .setContent((String)listMap.get(bxnrzyName + i));
            plBaoxiaoMx.setRemark((String)listMap.get(bzName + i));
            plBaoxiaoMx.setPlBaoxiao(plBaoxiao);
            this.plBaoxiaoMxManager.savePlBaoxiaoMx(plBaoxiaoMx);
          }
        }
        String isfentan = ServletRequestUtils.getStringParameter(request, "isfentan", "no");
        if (isfentan.equals("yes"))
        {
          PlFentanBase plFentanBase = null;
          if (isNew)
          {
            plFentanBase = new PlFentanBase();
            plFentanBase.setPlBaoxiao(plBaoxiao);
            plFentanBase.setUser(user);
            String ftNo = ServletRequestUtils.getStringParameter(request, "ftNo", "");
            plFentanBase.setFtNo(ftNo);
            plFentanBase.setCreatedate(new Date());
          }
          else
          {
            Integer id = new Integer(request.getParameter("fentanid"));
            plFentanBase = this.plFentanBaseManager.getPlFentanBase(id);
          }
          plFentanBase.setFtSum(Double.valueOf(ServletRequestUtils.getDoubleParameter(request, "ftSum", 0.0D)));
          this.plFentanBaseManager.savePlFentanBase(plFentanBase);
          
          Map<String, String> fentanFilter = new HashMap();
          fentanFilter.put("plFentanBaseXXid_i_eq", 
            plFentanBase.getId().toString());
          List<PlFentan> plFentans = this.plFentanManager
            .findPlFentan(fentanFilter);
          for (PlFentan plFentan : plFentans) {
            this.plFentanManager.removePlFentan(plFentan.getId());
          }
          int[] indexs = ServletRequestUtils.getIntParameters(request, "currIndex");
          int kumuid;
          int deptid;
          String begin;
          if (indexs != null)
          {
            sdf.applyPattern("yyyy-MM");
            for (int i = 0; i < indexs.length; i++)
            {
              int plFentan_id = ServletRequestUtils.getIntParameter(request, 
                "plFentan_id_" + indexs[i], -1);
              kumuid = ServletRequestUtils.getIntParameter(request, "kemu_id_" + 
                indexs[i], -1);
              deptid = ServletRequestUtils.getIntParameter(request, "dept_id_" + 
                indexs[i], -1);
              begin = ServletRequestUtils.getStringParameter(request, "beginDate_" + 
                indexs[i], "");
              String end = ServletRequestUtils.getStringParameter(request, "endDate_" + 
                indexs[i], "");
              double ftSum = ServletRequestUtils.getDoubleParameter(request, "ftSum_" + 
                indexs[i], -1.0D);
              int fkfs = ServletRequestUtils.getIntParameter(request, 
                "fkfs_" + indexs[i], -1);
              String remark = ServletRequestUtils.getStringParameter(request, "remark_" + 
                indexs[i], "");
              
              PlKemu plKemu = this.plKemuManager.getPlKemu(Integer.valueOf(kumuid));
              Dept dept = this.deptManager.getDept(Integer.valueOf(deptid));
              PlDicts plDicts = this.plDictsManager.getPlDicts(Integer.valueOf(fkfs));
              
              PlFentan ft = new PlFentan();
              ft.setCreatedate(new Date());
              ft.setPlFentanBase(plFentanBase);
              ft.setUser(user);
              
              Date beginDate = sdf.parse(begin);
              Date endDate = sdf.parse(end);
              ft.setBeginDate(beginDate);
              ft.setEndDate(endDate);
              
              ft.setDept(dept);
              ft.setFtSum(Double.valueOf(ftSum));
              ft.setKm(plKemu);
              ft.setPlDictsByFkfs(plDicts);
              ft.setRemark(remark);
              
              this.plFentanManager.savePlFentan(ft);
              
              Calendar calendar = Calendar.getInstance();
              calendar.setTime(beginDate);
              Calendar endCalendar = Calendar.getInstance();
              endCalendar.setTime(endDate);
              int n = 0;
              for (; !calendar.after(endCalendar); n++) {
                calendar.set(2, calendar.get(2) + 1);
              }
              calendar.setTime(beginDate);
              for (int j = 0; j < n; j++)
              {
                PlFentanMx mx = new PlFentanMx();
                mx.setPlFentan(ft);
                mx.setFtDate(sdf.format(calendar.getTime()));
                calendar.set(2, 
                  calendar.get(2) + 1);
                mx.setFtSum(Double.valueOf(ftSum / n));
                
                this.plFentanMxManager.savePlFentanMx(mx);
              }
            }
          }
          int[] hzids = ServletRequestUtils.getIntParameters(request, "hzid");
          if (hzids != null) {
            for (int hzid : hzids)
            {
              PlHuizong plHuizong = this.plHuizongManager
                .getPlHuizong(Integer.valueOf(hzid));
              plHuizong.setStatus(Integer.valueOf(1));
              plHuizong.setFlowfileId(workflowFile.getId());
              this.plHuizongManager.savePlHuizong(plHuizong);
            }
          }
        }
      }
    }
    if (this.workflowFileManager.findWorkflowNo(
      workflowFileinbox.getWorkflowFile()))
    {
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label31", "文件编号'") + 
        workflowFileinbox.getWorkflowFile().getFileno() + 
        "已重复,请重新输入文件编号!");
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + workflowFileinbox.getId());
    }
    if ((isUpload != null) && ("yes".equals(isUpload)))
    {
      int uploadres = uploadeFile(request, response, workflowFileinbox, mav);
      mav.addObject("uploadres", uploadres);
    }
    else if ((isUpload != null) && ("onlineCreate".equals(isUpload)))
    {
      onlineCreateFile(request, response, workflowFileinbox, mav);
    }
  }
  
  protected void onRemoveAll(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    





















    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInboxDraf(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->拟稿箱->删除", null);
    }
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    this.workflowFileManager.removeWorkflowFile(
      workflowFileinbox.getWorkflowFile().getId());
    saveMessage(request, getMessage(request, "common_label5", "成功删除"));
  }
  
  public ModelAndView draft(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_draft.jsp");
    
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    map.put("userXXid_i_eq", String.valueOf(user.getId()));
    map.put("issent_i_eq", "9");
    if (map.containsKey("catalogy_s_eq")) {
      map.remove("catalogy_s_eq");
    }
    if (map.containsKey("name_s_like")) {
      map.remove("name_s_like");
    }
    PageSortModel psm = new PageSortModel(request, "ec");
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager.findWorkflowFileinboxByPage(map, psm));
    
    mav.addAllObjects(referenceData(request));
    

    int id = ServletRequestUtils.getIntParameter(request, "inboxid", 0);
    if (id > 0) {
      try
      {
        WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(Integer.valueOf(id));
        this.workflowFileinboxManager.removeOpinion(workflowFileinbox);
      }
      catch (Exception localException) {}
    }
    return mav;
  }
  
  public ModelAndView removeDraft(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    if (request.getParameter("refreshFrame") != null) {
      return draft(request, response);
    }
    boolean iResult = false;
    
    Integer id = new Integer(request.getParameter("id"));
    

    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInboxDraf(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->拟稿箱->删除", null);
    }
    WorkflowFileinbox workflowFileinbox = null;
    try
    {
      workflowFileinbox = 
        this.workflowFileinboxManager.getWorkflowFileinbox(id);
    }
    catch (Exception e)
    {
      return draft(request, response);
    }
    Integer fileId = workflowFileinbox.getWorkflowFile().getId();
    
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    iResult = this.workflowFileinboxManager.removeWorkflowFileinboxDraft(id, 
      user);
    if (iResult)
    {
      this.workflowFilelockManager.removeWorkflowFilelock(fileId);
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label29", "删除草稿成功！"));
    }
    else
    {
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label30", "删除草稿失败，您可能无权删除此文件！"));
    }
    return draft(request, response);
  }
  
  public ModelAndView send(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=sent&id=");
    boolean isNew = ServletRequestUtils.getBooleanParameter(request, "isNew", false);
    
    onSave(request, response, mav, isNew, true);
    
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    String viewName = UrlUtil.getUrlParams(mav.getViewName(), map, "search_") + "&searchId=" + request.getParameter("searchId");
    mav.setViewName(viewName);
    return mav;
  }
  
  public ModelAndView member(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_member.jsp");
    
    Integer id = new Integer(request.getParameter("id"));
    Integer nextStepId = new Integer(request.getParameter("nextStepId"));
    









    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    
    mav.addObject("workflowFileinbox", workflowFileinbox);
    
    List nextStepList = this.workflowFileinboxManager.getNextStep(
      workflowFileinbox, nextStepId);
    
    mav.addObject("nextStepList", nextStepList);
    
    mav.addObject("nextStepUserMap", this.workflowFileinboxManager
      .getMembers(nextStepList, workflowFileinbox, 0));
    

    mav.addObject("controllStepId", 
      this.workflowFileinboxManager.getControllStepId());
    
    mav.addObject("isspecial", "0");
    
    return mav;
  }
  
  public ModelAndView special(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    
    mav.setViewName("/modules/workflow/workflowFileinbox_member.jsp");
    

    UserSession userSession = getUserSession(request);
    
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    if (!StringUtils.isBlank(workflowFileinbox.getWorkflowFile().getEndDesc()))
    {
      endFlowMessage(workflowFileinbox.getWorkflowFile(), request);
      mav.setViewName(this.successView);
      return mav;
    }
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(inboxId), "2")) {
      createPermException(request, "协同审批->待办公文->协办", null);
    }
    onSave(request, response, mav, false, false);
    try
    {
      mav.addObject("workflowFileinbox", workflowFileinbox);
      
      List nextStepList = this.workflowFileinboxManager
        .getSelfStep(workflowFileinbox);
      mav.addObject("nextStepList", nextStepList);
      
      mav.addObject("nextStepUserMap", 
        this.workflowFileinboxManager.getMembers(nextStepList, workflowFileinbox, 1));
      

      mav.addObject("controllStepId", "0");
      

      mav.addObject("isspecial", "1");
    }
    catch (Exception e)
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
    }
    return mav;
  }
  
  public ModelAndView specialBack(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    
    mav.setViewName("/modules/workflow/workflowFileinbox_member.jsp");
    

    onSave(request, response, mav, false, false);
    
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    






















    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    mav.addObject("workflowFileinbox", workflowFileinbox);
    
    List nextStepList = this.workflowFileinboxManager
      .getSelfStep(workflowFileinbox);
    
    mav.addObject("nextStepList", nextStepList);
    
    mav.addObject("nextStepUserMap", this.workflowFileinboxManager
      .getMembers(nextStepList, workflowFileinbox, 2));
    

    mav.addObject("controllStepId", "0");
    

    mav.addObject("isspecial", "2");
    

    return mav;
  }
  
  public ModelAndView getSpecial(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_special.jsp");
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    


    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(inboxId))) {
      createPermException(request, "协同审批->待办公文->取回协同", null);
    }
    String specialGetBack = request.getParameter("specialGetBack");
    
    String selectFile = request.getParameter("selectFile");
    

    List workflowFileinboxs = this.workflowFileinboxManager.findSpecial(inboxId);
    if ((!"ok".equalsIgnoreCase(specialGetBack)) && (!"no".equalsIgnoreCase(selectFile))) {
      if ((workflowFileinboxs == null) || (workflowFileinboxs.isEmpty())) {
        saveMessage(request, 
          getMessage(request, "WorkflowDictsManager_label60", "文件已被协办人签收，无法取回协办！"));
      }
    }
    mav.addObject("workflowFileinboxs", workflowFileinboxs);
    mav.addObject("sentStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.sentStatusEnum());
    mav.addObject("inboxId", inboxId);
    return mav;
  }
  
  public ModelAndView specialGetBack(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String inboxId = request.getParameter("inboxId");
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox.do?method=getSpecial&inboxId=" + 
      inboxId);
    


    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, inboxId)) {
      createPermException(request, "协同审批->待办公文->取回协同", null);
    }
    String[] ids = request.getParameterValues("itemlist");
    



















    boolean flag = true;
    if ((ids != null) && (ids.length > 0))
    {
      List<WorkflowFileinbox> workflowFileinboxs = this.workflowFileinboxManager.findSpecial(Integer.valueOf(inboxId));
      if ((workflowFileinboxs == null) || (workflowFileinboxs.isEmpty()))
      {
        saveMessage(request, 
          getMessage(request, "WorkflowDictsManager_label60", "文件已被协办人签收，无法取回协办！"));
        
        mav.setViewName("/modules/workflow/workflowFileinbox.do?method=getSpecial&inboxId=" + inboxId + "&specialGetBack=ok");
      }
      else
      {
        int fileNum = workflowFileinboxs.size();
        
        StringBuffer idSb = new StringBuffer();
        
        Iterator localIterator = workflowFileinboxs.iterator();
        int i=0; 
        while (localIterator.hasNext())
        {
          WorkflowFileinbox box = (WorkflowFileinbox)localIterator.next();
          if (ids[i].equals(String.valueOf(box.getId()))) {
            idSb.append(ids[i]).append(",");
          }
          i++;
        }
        if (idSb.length() > 0)
        {
          idSb.deleteCharAt(idSb.length() - 1);
          String[] boxIds = idSb.toString().split(",");
          flag = this.workflowFileinboxManager.saveGetbackSpecial(boxIds);
          if (!flag)
          {
            saveMessage(request, 
              getMessage(request, "WorkflowFileinboxManagerController_label58", "文件编号'"));
          }
          else
          {
            saveMessage(request, 
              getMessage(request, "WorkflowDictsManager_label24", "协办取回成功！"));
            
            mav.setViewName("/modules/workflow/workflowFileinbox.do?method=getSpecial&inboxId=" + inboxId + "&specialGetBack=ok");
          }
        }
        else
        {
          saveMessage(request, 
            getMessage(request, "WorkflowDictsManager_label60", "文件已被协办人签收，无法取回协办！"));
          
          mav.setViewName("/modules/workflow/workflowFileinbox.do?method=getSpecial&inboxId=" + inboxId + "&specialGetBack=ok");
        }
      }
    }
    else
    {
      saveMessage(request, 
        getMessage(request, "WorkflowDictsManager_label59", "请选择要取回的协办步骤！"));
      
      mav.setViewName("/modules/workflow/workflowFileinbox.do?method=getSpecial&inboxId=" + inboxId + "&selectFile=no");
    }
    return mav;
  }
  
  public ModelAndView sent(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    Integer id = new Integer(request.getParameter("id"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    if (!StringUtils.isBlank(workflowFileinbox.getWorkflowFile().getEndDesc()))
    {
      endFlowMessage(workflowFileinbox.getWorkflowFile(), request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->待办公文->发送", null);
    }
    if (this.workflowFileManager.findWorkflowNo(
      workflowFileinbox.getWorkflowFile())) {
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label31", "文件编号'") + 
        workflowFileinbox.getWorkflowFile().getFileno() + 
        getMessage(request, 
        "WorkflowFileinboxManagerController_label32", 
        "'已重复!"));
    }
    this.workflowFilelockManager.removeWorkflowFilelock(workflowFileinbox);
    

    this.workflowFileattachManager.removeBlankAttach(
      workflowFileinbox.getWorkflowFile().getId());
    if ((workflowFileinbox.getWorkflowStep().getSteptypeId().intValue() == 2) || 
      (workflowFileinbox.getWorkflowStep().getSteptypeId().intValue() == 3))
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_step_user.jsp");
      mav.addObject("workflowFileinbox", workflowFileinbox);
      mav.addObject("nextStepList", 
        this.workflowFileinboxManager.getNextStep(workflowFileinbox));
    }
    else
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_member.jsp");
      
      mav.addObject("workflowFileinbox", workflowFileinbox);
      
      List nextStepList = this.workflowFileinboxManager
        .getNextStep(workflowFileinbox);
      
      mav.addObject("nextStepList", nextStepList);
      



      mav.addObject("nextStepUserMap", 
        this.workflowFileinboxManager.getMembers(nextStepList, workflowFileinbox, 0));
      

      mav.addObject("controllStepId", 
        this.workflowFileinboxManager.getControllStepId());
      
      mav.addObject("isspecial", "0");
      



      this.workflowFileinboxManager.doDelivery(mav, workflowFileinbox.getWorkflowFile());
    }
    mav.addObject("SMS", org.springside.core.Constants.SMS);
    

    return mav;
  }
  
  public ModelAndView finish(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    long start = System.currentTimeMillis();
    
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_finish.jsp");
    
    int isSuccess = 1;
    Integer id = new Integer(request.getParameter("id"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
    WorkflowFile workflowFile = workflowFileinbox.getWorkflowFile();
    if (!StringUtils.isBlank(workflowFile.getEndDesc()))
    {
      endFlowMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->待办公文->退回", null);
    }
    if (workflowFile.getFlowFlag().intValue() == 5)
    {
      saveNullifyMessage(workflowFile, request);
      mav.setViewName(this.successView);
      return mav;
    }
    if ((workflowFile.getFlowFlag() != null) && (workflowFile.getFlowFlag().intValue() == 0))
    {
      WorkflowFlowtype workflowFlowtype = workflowFile.getWorkflowFlowtype();
      if ((workflowFlowtype.getFilenoAuto() != null) && (workflowFlowtype.getFilenoAuto().intValue() == 3)) {
        try
        {
          WorkflowFileno workflowFileno = this.workflowFileinboxManager.saveFileno(workflowFileinbox);
          if ((workflowFileno != null) && (!StringUtils.isBlank(workflowFileno.getFilenoLast())))
          {
            String[] fileno = workflowFileno.getFilenoLast().split("@");
            








            int fileNoStart = workflowFlowtype.getFilenoStart().intValue();
            if ((workflowFileno.getFilenoValue() != null) && (fileNoStart > workflowFileno.getFilenoValue().intValue()))
            {
              String newFileNo = "";
              String format = "%03d";
              if (fileno[1] != null)
              {
                int len = fileno[1].trim().length();
                if (len > 3) {
                  format = "%0" + len + "d";
                }
              }
              try
              {
                newFileNo = String.format(format, new Object[] { Integer.valueOf(fileNoStart) });
              }
              catch (Exception e)
              {
                System.out.println("格式化起始编号异常：" + e.getMessage());
              }
              if (!StringUtils.isBlank(newFileNo))
              {
                workflowFile.setFileno(newFileNo);
                workflowFileno = this.workflowFileinboxManager.saveFileno(workflowFileinbox, Integer.valueOf(fileNoStart));
              }
            }
            else if (fileno.length == 3)
            {
              workflowFile.setFileno(fileno[0].trim() + fileno[1].trim() + fileno[2].trim());
            }
          }
        }
        catch (BusinessException e)
        {
          e.printStackTrace();
        }
      }
    }
    Integer stepCount = new Integer(request.getParameter("stepCount"));
    Integer controllStepId = new Integer(request.getParameter("controllStepId"));
    Integer isspecial = new Integer(request.getParameter("isspecial"));
    String leaveword = request.getParameter("leaveword");
    
    Map map = WebUtils.getParametersStartingWith(request, "nextstep_");
    int status = -1;
    int sms = ServletRequestUtils.getIntParameter(request, "sms", 0);
    if (isspecial.intValue() == 1)
    {
      if (!this.workflowFileinboxManager.saveSpecialStep(id, map, stepCount, 
        leaveword, sms, request)) {
        isSuccess = 0;
      }
    }
    else if (isspecial.intValue() == 2)
    {
      this.workflowFileinboxManager.saveSpecialBackStep(id, map, stepCount, 
        leaveword, request);
    }
    else
    {
      status = this.workflowFileinboxManager.saveStep(id, map, stepCount, 
        controllStepId, leaveword, Integer.valueOf(sms), request);
      if (status == 0)
      {
        isSuccess = 0;
      }
      else if (status == 2)
      {
        this.workflowFilelockManager.removeWorkflowFilelock(workflowFileinbox
          .getWorkflowFile().getId());
      }
      else if (status == -1)
      {
        mav.addObject("isSuccess", Integer.valueOf(1));
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label43", "此节点文件可能已经被取回或者被删除！"));
        return mav;
      }
    }
    if (!"".equals(this.workflowFileinboxManager.getMessage())) {
      saveMessage(request, this.workflowFileinboxManager.getMessage());
    }
    mav.addObject("isSuccess", Integer.valueOf(isSuccess));
    if (isspecial.intValue() != 1) {
      this.workflowFileinboxManager.saveApproveOpinion(workflowFileinbox);
    }
    if ((isspecial.intValue() != 1) && (isspecial.intValue() != 2) && (status == 2)) {
      this.workflowFileinboxManager.archive(workflowFileinbox);
    }
    mav.addObject("workflowFileinbox", workflowFileinbox);
    




    mav.addObject("currentFileinboxes", 
      this.workflowFileinboxManager
      .findCurrentFileinbox(workflowFile.getId()));
    
    mav.addObject("workflowFileprocesses", 
      this.workflowFileinboxManager
      .findWorkflowFileprocess(workflowFile.getId()));
    
    mav.addObject("processStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.processStatusEnum());
    
    mav.addObject("sentStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.sentStatusEnum());
    

    UserSession usersession = (UserSession)request.getSession()
      .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
    Set<User> rusers = workflowFile
      .getAttentionUsers();
    for (User user : rusers) {
      this.messagesManager.sendMessages(this.userManager
        .getUser(usersession.getId()), user.getId().toString(), new Title("公文已办理", 
        "请留意", "公文处理"), usersession.getName() + "在《" + 
        workflowFileinbox.getWorkflowStep().getName() + "》步骤对《" + 
        workflowFile.getTitle() + "》完成办理", 
        "", workflowFileinbox.getClass().getName(), 
        workflowFileinbox.getId(), Integer.valueOf(2));
    }
    if ((workflowFileinbox.getWishdate2() != null) && 
      (new Date().after(workflowFileinbox.getWishdate2())))
    {
      WorkflowStep workflowStep = workflowFileinbox.getWorkflowStep();
      if ((workflowStep.getUsers1() != null) && (!"".equals(workflowStep.getUsers1())))
      {
        String[] userIds = workflowStep.getUsers1().split(",");
        for (int j = 0; j < userIds.length; j++)
        {
          User user = this.userManager.getUser(new Integer(userIds[j]));
          this.messagesManager.sendMessages(this.userManager
            .getUser(usersession.getId()), user.getId().toString(), new Title("流程延时处理", 
            "请留意", "延时流程"), usersession.getName() + "在《" + 
            workflowFileinbox.getWorkflowStep().getName() + "》步骤对《" + 
            workflowFileinbox.getWorkflowFile().getTitle() + "》延时办理", 
            "", workflowFileinbox.getClass().getName(), 
            workflowFileinbox.getId(), Integer.valueOf(2));
        }
      }
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < stepCount.intValue(); i++)
    {
      String users = (String)map.get("users_" + 
        String.valueOf(i + 1));
      sb.append(users).append(",");
    }
    if (sb.length() > 0) {
      sb.deleteCharAt(sb.length() - 1);
    }
    mav.addObject("sendTousers", sb.toString());
    mav.addObject("sms", Integer.valueOf(sms));
    mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=finishSuccess&id=" + 
      id + 
      "&isSuccess=" + 
      isSuccess + 
      "&isspecial=" + 
      isspecial);
    
    String searchId = request.getParameter("searchId");
    
    Map map1 = WebUtils.getParametersStartingWith(request, "search_");
    String viewName = UrlUtil.getUrlParams(mav.getViewName(), map1, "search_") + "&searchId=" + request.getParameter("searchId");
    mav.setViewName(viewName);
    
    long end = System.currentTimeMillis();
    this.logger.info("execute time : " + (end - start) + "/ms [method:finish]");
    
    return mav;
  }
  
  public ModelAndView finishSuccess(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_finish.jsp");
    
    Integer id = new Integer(request.getParameter("id"));
    Integer isSuccess = new Integer(request.getParameter("isSuccess"));
    mav.addObject("isSuccess", isSuccess);
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    
















































    mav.addObject("workflowFileinbox", workflowFileinbox);
    






















    mav.addObject("currentFileinboxes", 
      this.workflowFileinboxManager
      .findCurrentFileinbox(workflowFileinbox.getWorkflowFile().getId()));
    
    mav.addObject("workflowFileprocesses", 
      this.workflowFileinboxManager
      .findWorkflowFileprocess(workflowFileinbox.getWorkflowFile().getId()));
    
    mav.addObject("processStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.processStatusEnum());
    
    mav.addObject("sentStatusEnum", 
      cn.firstsoft.modules.workflow.Constants.sentStatusEnum());
    if ("1".equals(ServletRequestUtils.getStringParameter(request, "endFlow")))
    {
      WorkflowFileprocess process = this.workflowFileinboxManager.getFileProcess(workflowFileinbox.getWorkflowFile().getId());
      
      saveMessage(request, getMessage(request, "workflowFileinbox_edit_label110", "该文件已经被审批人") + 
        "[" + process.getUserByUserPid().getName() + "]" + 
        getMessage(request, getMessage(request, "workflowFileinbox_edit_label111", "结束")));
    }
    String userIds = request.getParameter("sendTousers");
    String sms = request.getParameter("sms");
    StringBuffer userNames = new StringBuffer();
    StringBuffer noMobileUser = new StringBuffer();
    if ((userIds != null) && (!"".equals(userIds)))
    {
      String[] idsArr = userIds.split(",");
      if (idsArr.length > 0) {
        for (String userid : idsArr) {
          if ((userid != null) && (!"".equals(userid)))
          {
            User u = this.userManager.getUser(Integer.valueOf(userid));
            if ((u.getMobile() == null) || ("".equals(u.getMobile().trim()))) {
              noMobileUser.append(u.getName()).append(" ");
            }
            userNames.append(u.getName()).append(" ");
          }
        }
      }
    }
    String isForwardToOutbox = org.springside.core.Constants.IS_FORWARD_TO_OUT_BOX;
    if ((isSuccess.intValue() == 1) && ("yes".equals(isForwardToOutbox)))
    {
      mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=list");
      saveMessage(request, this.workflowFileinboxManager.getMessage());
    }
    if (("1".equals(sms)) && (noMobileUser != null) && (!"".equals(noMobileUser.toString()))) {
      saveMessage(request, "手机短信因" + noMobileUser.toString() + "无手机号码无法正常发送");
    }
    return mav;
  }
  
  public ModelAndView getback(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    

    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->待办公文->取回", null);
    }
    if (this.workflowFileinboxManager.saveGetback(id))
    {
      ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + id);
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label33", "已经从下一节点取回所有的文件！"));
      
      return mav;
    }
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox.do?method=show&id=" + id);
    saveMessage(request, 
    
      getMessage(request, "WorkflowFileinboxManagerController_label34", "由于下一节点用户刚刚签收或者本节点其他人送出了文件，因此不能再取回！"));
    return mav;
  }
  
  public ModelAndView returnBack(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    




















    WorkflowFileinbox workflowFileinbox = null;
    try
    {
      workflowFileinbox = 
        this.workflowFileinboxManager.getWorkflowFileinbox(id);
    }
    catch (Exception e)
    {
      this.logger.error(e);
    }
    ModelAndView mav = new ModelAndView();
    if (!StringUtils.isBlank(workflowFileinbox.getWorkflowFile().getEndDesc()))
    {
      endFlowMessage(workflowFileinbox.getWorkflowFile(), request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->待办公文->退回", null);
    }
    if (workflowFileinbox == null)
    {
      mav = new ModelAndView("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label43", "此节点文件可能已经被取回或者被删除！"));
      return mav;
    }
    this.workflowFilelockManager.removeWorkflowFilelock(workflowFileinbox);
    
    WorkflowFile workflowFile = null;
    WorkflowStep workflowStep = null;
    List workflowFileinboxList = null;
    String formfile = null;
    if ("yes".equals(org.springside.core.Constants.WORKFLOW_RETURN_DOCEX))
    {
      workflowFile = workflowFileinbox.getWorkflowFile();
      workflowStep = workflowFileinbox.getWorkflowStep();
      


      Map map = new HashMap();
      map.put("workflowFileXXid_i_eq", String.valueOf(
        workflowFile.getId()));
      map.put("workflowStepXXid_i_eq", String.valueOf(
        workflowStep.getId()));
      map.put("issent_i_in", "2,3,4");
      

      workflowFileinboxList = this.workflowFileinboxManager
        .findWorkflowFileinbox(map);
      

      String urlStr = "http://127.0.0.1:" + 
        request.getLocalPort() + 
        request.getContextPath() + 
        "/workflowArchive.do?method=archive&openwin=true&process=false&id=" + 
        
        StrUtils.getEncString(workflowFile.getId().toString());
      

      formfile = "/workflow/temporary/" + 
        DateUtil.getOnlyID();
      try
      {
        FileUtil.writeHttpFile(urlStr, formfile);
      }
      catch (Exception e)
      {
        this.logger.info("由于以下错误，表单传阅未能成功！\n" + e);
      }
    }
    String remarks = ServletRequestUtils.getStringParameter(request, "remarks", "");
    if (this.workflowFileinboxManager.saveReturnback(id, remarks))
    {
      mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?ec_s_startdate=desc&searchId=" + request.getParameter("searchId"));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label35", "已经将文件退回到上一节点！"));
      














      String command = request.getParameter("command");
      if ("saveOpinionx".equals(command))
      {
        String optionvalue = request.getParameter("optionvalue");
        String[] ov = optionvalue.split("!,,!");
        
        WorkflowShortopinion workflowShortopinion = this.workflowShortopinionManager.getWorkflowShortopinion(new Integer(ov[1]));
        this.workflowFileinboxManager.saveOpinion(workflowFileinbox, workflowShortopinion.getName(), ov[0]);
      }
      else
      {
        String[] ov;
        if ("saveOpinion".equals(command))
        {
          String optionvalue = request.getParameter("optionvalue");
          ov = optionvalue.split("!,,!");
          this.workflowFileinboxManager.saveOpinion(workflowFileinbox, ov[1], ov[0]);
        }
        else if ("saveSign".equals(command))
        {
          String optionvalue = request.getParameter("optionvalue");
          ov = optionvalue.split("!,,!");
        }
      }
      Map ajaxopinionMap = WebUtils.getParametersStartingWith(request, "ajaxopinion_");
      
      Set keys1 = ajaxopinionMap.keySet();
      String value;
      for (Object key : keys1)
      {
        String myKey = (String)key;
        value = String.valueOf(ajaxopinionMap.get(myKey));
        String opinionStr = request.getParameter(myKey);
        String blankOpinion = ServletRequestUtils.getStringParameter(request, "blankOpinion", "");
        if (opinionStr == null) {
          opinionStr = "";
        }
        this.logger.info(opinionStr + "  ---  " + blankOpinion);
        if (opinionStr.equals(blankOpinion)) {
          opinionStr = "";
        }
        if (("1".equals(value)) && (!"".equals(opinionStr))) {
          this.workflowFileinboxManager.saveAjaxOpinion(
            workflowFileinbox, opinionStr, myKey.replace("str", ""));
        }
      }
      this.workflowFileinboxManager.saveUpdateStatus(workflowFileinbox);
      
      Map singleopinionMap = WebUtils.getParametersStartingWith(request, "singleopinion_");
      
      Set keys = singleopinionMap.keySet();
      for (Object key : keys)
      {
        String myKey = (String)key;
        String value1 = String.valueOf(singleopinionMap.get(myKey));
        if ("1".equals(value1))
        {
          String opinionStr = request.getParameter(myKey);
          if (opinionStr == null) {
            opinionStr = "";
          }
          this.workflowFileinboxManager.saveSingleOpinion(workflowFileinbox, opinionStr, myKey.replace("str", ""));
        }
      }
      this.workflowFileinboxManager.saveApproveOpinion(workflowFileinbox);
      


      this.messagesManager.removeRealMessages(userSession.getId(), "cn.firstsoft.modules.workflow.domain.WorkflowFileinbox", workflowFileinbox.getId());
      if ("yes".equals(org.springside.core.Constants.WORKFLOW_RETURN_DOCEX))
      {
        Date createdate = DateUtil.getDate();
        
        UserSession user = (UserSession)request.getSession()
          .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
        DocexFile docexFile = new DocexFile();
        String title = workflowFile.getTitle() + 
          getMessage(request, 
          "WorkflowFileinboxManagerController_label36", 
          "，公文退回传阅！");
        
        String content = 
        
          getMessage(request, "WorkflowFileinboxManagerController_label37", "此文件为公文退回自动传阅文件，在节点【") + 
          workflowStep.getName() + 
          getMessage(request, 
          "WorkflowFileinboxManagerController_label38", 
          "】被用户【") + 
          user.getName() + 
          getMessage(request, 
          "WorkflowFileinboxManagerController_label39", 
          "】退回！");
        
        docexFile.setTitle(title);
        docexFile.setCreatedate(createdate);
        User fromUser = this.userManager.getUser(user.getId());
        docexFile.setUser(fromUser);
        




















        docexFile.setStatus(Integer.valueOf(1));
        




















        docexFile.setPriority(Integer.valueOf(2));
        docexFile.setIsShare(Integer.valueOf(1));
        docexFile.setIsConcerm(Integer.valueOf(1));
        

        docexFile.setContent("");
        docexFile.setAdditional(Integer.valueOf(1));
        docexFile.setIsFree("F");
        
        docexFile.setFileType(org.springside.core.Constants.DOCEXFILE_TYPE.toString());
        
        docexFile.setIsDraft(Integer.valueOf(0));
        
        String userids = "";
        String usernames = "";
        int pos = 0;
        for (int i = 0; i < workflowFileinboxList.size(); i++)
        {
          WorkflowFileinbox workflowFileinbox1 = 
            (WorkflowFileinbox)workflowFileinboxList.get(i);
          DocexFiledetail docexFiledetail = new DocexFiledetail();
          docexFiledetail.setCreatedate(DateUtil.getDate());
          
          docexFiledetail.setIslabel(Integer.valueOf(0));
          
          docexFiledetail.setIsread(Integer.valueOf(0));
          
          docexFiledetail.setStatus(Integer.valueOf(0));
          docexFiledetail.setDocexFile(docexFile);
          docexFiledetail.setUserByReaduserId(
            workflowFileinbox1.getUser());
          





















          docexFiledetail.setPos(Integer.valueOf(pos));
          pos++;
          




















          docexFiledetail.setIsConcerm(docexFile.getId());
          




















          docexFiledetail.setIssent(Integer.valueOf(1));
          docexFiledetail.setSentdate(null);
          




















          docexFiledetail.setStepId(Integer.valueOf(0));
          




















          docexFiledetail.setStepUserId(Integer.valueOf(0));
          
          docexFiledetail.setStepUserId(Integer.valueOf(0));
          docexFiledetail.setParentId(Integer.valueOf(0));
          
          docexFile.getDocexFiledetails().add(docexFiledetail);
          if ("".equals(usernames))
          {
            userids = String.valueOf(workflowFileinbox1.getUser()
              .getId());
            usernames = workflowFileinbox1.getUser().getName();
          }
          else
          {
            userids = 
            
              userids + "," + String.valueOf(workflowFileinbox1.getUser()
              .getId());
            usernames = usernames + "," + 
              workflowFileinbox1.getUser().getName();
          }
        }
        docexFile.setUsers(userids);
        docexFile.setDepts("");
        





















        String serverfile = "";
        String filename = "";
        String fileext = "";
        long filesize = 0L;
        
        String attachs = "";
        

        String serverdir = this.docexFileManager
          .getDocexParentPath(docexFile);
        

        serverdir = serverdir + "/" + DateUtil.getOnlyID();
        if (!StorageUtil.exists(serverdir)) {
          StorageUtil.mkdir(serverdir);
        }
        if (formfile != null) {
          if (StorageUtil.exists(formfile))
          {
            String des = serverdir + "/" + DateUtil.getOnlyID();
            StorageUtil.copy(formfile, des);
            DocexFileattach docexFileattach = new DocexFileattach();
            docexFileattach.setCreatedate(createdate);
            docexFileattach.setDocexFile(docexFile);
            docexFileattach.setFileext("text/plain");
            String fileName = workflowFile.getTitle();
            fileName = fileName
              .replaceAll("[#$%\\\\/:*?\"<>|\\s]", "-") + 
              ".html";
            docexFileattach.setFilename(fileName);
            docexFileattach.setFilesize(Integer.valueOf(
              (int)StorageUtil.getSize(formfile)));
            docexFileattach.setServerfile(des);
            docexFileattach.setUserId(user.getId());
            

            docexFileattach.setUserName(user.getName());
            docexFileattach.setVer(Integer.valueOf(1));
            docexFileattach.setLastver(Integer.valueOf(1));
            




















            docexFileattach.setType(Integer.valueOf(0));
            docexFileattach
              .setTopicId(UUID.randomUUID().toString());
            docexFileattach.setDocType("unknown");
            docexFileattach.setTopicName("");
            
            docexFile.getDocexFileattachs().add(docexFileattach);
          }
        }
        Iterator iterator = workflowFile.getWorkflowFileattaches()
          .iterator();
        while (iterator.hasNext())
        {
          WorkflowFileattach workflowFileattach1 = 
            (WorkflowFileattach)iterator.next();
          String src = workflowFileattach1.getServerfile();
          if (workflowFileattach1.getVer().intValue() == 
            workflowFileattach1.getLastver().intValue()) {
            if (StorageUtil.exists(src))
            {
              String des = serverdir + "/" + DateUtil.getOnlyID();
              




















              StorageUtil.copy(src, des, true);
              DocexFileattach docexFileattach = new DocexFileattach();
              docexFileattach.setCreatedate(createdate);
              docexFileattach.setDocexFile(docexFile);
              docexFileattach.setFileext(
                workflowFileattach1.getFileext());
              docexFileattach.setFilename(
                workflowFileattach1.getFilename());
              docexFileattach.setFilesize(Integer.valueOf(Integer.parseInt(
                String.valueOf(StorageUtil.getSize(des)))));
              docexFileattach.setServerfile(des);
              docexFileattach.setUserId(user.getId());
              docexFileattach.setUserName(user.getName());
              
              docexFileattach.setVer(Integer.valueOf(1));
              docexFileattach.setLastver(Integer.valueOf(1));
              




















              docexFileattach.setType(Integer.valueOf(0));
              docexFileattach
                .setTopicId(UUID.randomUUID().toString());
              filename = workflowFileattach1.getFilename();
              if ((filename.toLowerCase().endsWith(".doc")) || 
                (filename.toLowerCase().endsWith(".docx"))) {
                docexFileattach.setDocType("doc");
              } else if ((filename.toLowerCase().endsWith(".xls")) || 
                (filename.toLowerCase().endsWith(".xlsx"))) {
                docexFileattach.setDocType("xls");
              } else {
                docexFileattach.setDocType("unknown");
              }
              docexFileattach.setTopicName("");
              
              docexFile.getDocexFileattachs().add(docexFileattach);
            }
          }
        }
        String uuid = UUID.randomUUID().toString();
        String des = serverdir + "/" + uuid;
        
        String src = "/workflow/template/blank.doc";
        
        StorageUtil.copy(src, des);
        DocexFileattach docexFileattach = new DocexFileattach();
        docexFileattach.setDocexFile(docexFile);
        docexFileattach.setCreatedate(createdate);
        docexFileattach.setServerfile(des);
        docexFileattach.setFilename("正文.doc");
        docexFileattach.setFileext("application/msword");
        docexFileattach.setFilesize(Integer.valueOf((int)StorageUtil.getSize(des)));
        docexFileattach.setUserId(user.getId());
        docexFileattach.setUserName(user.getName());
        
        docexFileattach.setVer(Integer.valueOf(1));
        docexFileattach.setLastver(Integer.valueOf(1));
        
        docexFileattach.setType(Integer.valueOf(1));
        docexFileattach.setTopicId(uuid);
        docexFileattach.setDocType("doc");
        docexFileattach.setTopicName("");
        
        docexFile.getDocexFileattachs().add(docexFileattach);
        

        docexFile.setFileType(org.springside.core.Constants.DOCEXFILE_TYPE.toString());
        docexFile.setFromType("1");
        










        this.docexFileManager.saveDocexFileWithMessage(docexFile);
        

        serverdir = this.docexFileManager.getDocexParentPath(docexFile);
        serverdir = serverdir + "/" + docexFile.getId();
        if (!StorageUtil.exists(serverdir)) {
          StorageUtil.mkdir(serverdir);
        }
        String contentFile = serverdir + "/" + "content.htm";
        StorageUtil.writeFile(content, contentFile);
        
        saveMessage(request, 
        
          getMessage(request, "WorkflowFileinboxManagerController_label40", "已经将此文件传阅给") + 
          "：" + 
          usernames + 
          getMessage(request, 
          "WorkflowFileinboxManagerController_label41", 
          "，文件会保留在这些用户的传阅箱中！"));
      }
      return mav;
    }
    mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + id);
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    String viewName = UrlUtil.getUrlParams(mav.getViewName(), map, "search_") + "&searchId=" + request.getParameter("searchId");
    mav.setViewName(viewName);
    saveMessage(request, 
    
      getMessage(request, "WorkflowFileinboxManagerController_label42", "有可能跨越分支合并节点，不能退回此文件！"));
    if (("yes".equals(org.springside.core.Constants.WORKFLOW_RETURN_DOCEX)) && 
      (formfile != null)) {
      StorageUtil.delete(formfile);
    }
    return mav;
  }
  
  public ModelAndView checkin(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    


    UserSession userSession = getUserSession(request);
    





    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
    if ((workflowFileinbox != null) && 
      (workflowFileinbox.getWorkflowFile().getEndUser() != null))
    {
      User user = this.userManager.getUser(workflowFileinbox.getWorkflowFile().getEndUser().getId());
      createPermException(request, "协同审批->待办公文->签收", getMessage(request, "workflow_show1_label26", "该公文已经被审批人") + user.getName() + getMessage(request, "workflow_show1_label27", "结束！"));
    }
    if (this.workflowFileinboxManager.saveCheckin(id))
    {
      ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + id);
      
      Map map = WebUtils.getParametersStartingWith(request, "search_");
      String viewName = UrlUtil.getUrlParams(mav.getViewName(), map, "search_") + "&searchId=" + request.getParameter("searchId");
      mav.setViewName(viewName);
      return mav;
    }
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_finish.jsp");
    mav.addObject("isSuccess", Integer.valueOf(1));
    saveMessage(request, 
    
      getMessage(request, "WorkflowFileinboxManagerController_label43", "此节点文件可能已经被取回或者被删除！"));
    return mav;
  }
  
  public ModelAndView addHangup(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    




    UserSession userSession = getUserSession(request);
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
    if (!StringUtils.isBlank(workflowFileinbox.getWorkflowFile().getEndDesc()))
    {
      ModelAndView mav = new ModelAndView();
      endFlowMessage(workflowFileinbox.getWorkflowFile(), request);
      mav.setViewName(this.successView);
      return mav;
    }
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(id), "7")) {
      createPermException(request, "协同审批->待办公文->缓办", null);
    }
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + id);
    try
    {
      this.workflowFileinboxManager.saveHangup(id);
      
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label44", "此文件已经被缓办！"));
    }
    catch (Exception e)
    {
      mav.setViewName("/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label25", "此节点文件可能被取回或者被其他人删除!"));
    }
    Map map = WebUtils.getParametersStartingWith(request, "search_");
    mav.setViewName(UrlUtil.getUrlParams(mav.getViewName(), map, "search_"));
    return mav;
  }
  
  public ModelAndView attention(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    


    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->待办公文->收藏", null);
    }
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox.do?method=show&id=" + id);
    String message = "";
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    if ((workflowFileinbox.getIsattention() != null) && 
      (workflowFileinbox.getIsattention().intValue() == 1))
    {
      workflowFileinbox.setIsattention(Integer.valueOf(0));
      this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox, 
        false, false);
      
      message = getMessage(request, 
        "WorkflowFileinboxManagerController_label45", "此文件已经被移出收藏！");
    }
    else
    {
      workflowFileinbox.setIsattention(Integer.valueOf(1));
      this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox, 
        false, false);
      message = getMessage(request, 
        "WorkflowFileinboxManagerController_label46", "此文件已经被加入收藏！");
    }
    saveMessage(request, message);
    return mav;
  }
  
  public ModelAndView signature(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_signature.jsp");
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    Map filter = new HashMap();
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    filter.put("userId_i_eq", String.valueOf(user.getId()));
    filter.put("status_i_eq", "1");
    Map<String, String> orderFilter = new HashMap();
    orderFilter.put("id", "asc");
    orderFilter.put("defaultsign", "desc");
    List<WorkflowSignature> workflowSignatures = this.workflowSignatureManager.findWorkflowSignature(filter, orderFilter);
    workflowSignatures = this.workflowSignatureManager.savedefault(workflowSignatures);
    workflowSignatures = this.workflowSignatureManager.getIfpass(workflowSignatures);
    String ifshow = "1";
    if (workflowSignatures.size() > 0) {
      ifshow = ((WorkflowSignature)workflowSignatures.get(0)).getIfpasswrod();
    }
    mav.addObject("ifshow", ifshow);
    mav.addObject("workflowSignatures", workflowSignatures);
    mav.addObject("workflowFileinbox", workflowFileinbox);
    String signField = request.getParameter("signField");
    mav.addObject("signField", signField);
    return mav;
  }
  
  public ModelAndView saveSignature(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    Integer signId = new Integer(request.getParameter("signId"));
    
    WorkflowSignature workflowSignature = this.workflowSignatureManager
      .getWorkflowSignature(signId);
    
    String signField = request.getParameter("signField");
    
    String password = request.getParameter("password");
    
    PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
    
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_signature.jsp");
    Map filter = new HashMap();
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    filter.put("userId_i_eq", String.valueOf(user.getId()));
    filter.put("status_i_eq", "1");
    mav.addObject("workflowSignatures", 
      this.workflowSignatureManager.findWorkflowSignature(filter));
    mav.addObject("workflowFileinbox", workflowFileinbox);
    mav.addObject("signField", signField);
    if ((StringUtils.isNotEmpty(password)) && 
      (workflowSignature.getPassword().equals(
      passwordEncoder.encodePassword(password, null))))
    {
      this.workflowFileinboxManager.saveSignature(workflowFileinbox, 
        workflowSignature, signField);
      
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label47", "签名签章成功！"));
      
      mav.addObject("success", "1");
    }
    else
    {
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label48", "签名签章密码不正确，签名不成功！"));
    }
    return mav;
  }
  
  public ModelAndView fileno(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_fileno.jsp");
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    WorkflowFileno workflowFileno = this.workflowFileinboxManager
      .getWorkflowFileno(workflowFileinbox);
    if (workflowFileno != null)
    {
      mav.addObject("workflowFileno", workflowFileno);
      mav.addObject("fileno", " @  @ ");
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label49", "点取新号按钮获得最新的号码！"));
    }
    else
    {
      mav.addObject("fileno", " @  @ ");
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label50", "表单中用于产生文件编号的数据不完善，暂时不能产生编号！"));
    }
    mav.addObject("workflowFileinbox", workflowFileinbox);
    
    return mav;
  }
  
  public ModelAndView subword(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_subword.jsp");
    
    String init = request.getParameter("init");
    if ("0".equals(init))
    {
      mav.addObject("subword", "");
    }
    else
    {
      String title = request.getParameter("title");
      if (title == null) {
        title = "";
      }
      mav.addObject("subword", 
        this.subwordItemManager.getSubwordAnalyse(title));
    }
    return mav;
  }
  
  public ModelAndView saveFileno(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    Integer id = new Integer(request.getParameter("id"));
    String fileno1 = request.getParameter("fileno1");
    if (fileno1 == null) {
      fileno1 = "";
    }
    Integer fileno2 = new Integer(request.getParameter("fileno2"));
    String fileno3 = request.getParameter("fileno3");
    if (fileno3 == null) {
      fileno3 = "";
    }
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_fileno.jsp");
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    WorkflowFileno workflowFileno = this.workflowFileinboxManager
      .saveFilenoAdjust(workflowFileinbox, id, fileno2);
    if (workflowFileno != null)
    {
      mav.addObject("workflowFileno", workflowFileno);
      mav.addObject("fileno", fileno1 + " @ " + 
        workflowFileno.getFilenoLast() + " @ " + fileno3);
    }
    else
    {
      mav.addObject("fileno", " @  @ ");
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label50", "表单中用于产生文件编号的数据不完善，暂时不能产生编号！"));
    }
    mav.addObject("workflowFileinbox", workflowFileinbox);
    
    return mav;
  }
  
  public ModelAndView opinion(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_opinion.jsp");
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    Map filter = new HashMap();
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    filter.put("userId_i_eq", String.valueOf(user.getId()));
    mav.addObject("workflowShortopinions", 
      this.workflowShortopinionManager.findWorkflowShortopinion(filter));
    mav.addObject("workflowFileinbox", workflowFileinbox);
    String signField = request.getParameter("signField");
    mav.addObject("signField", signField);
    if (!"add".equals(org.springside.core.Constants.WORKFLOW_OPINION_MODE))
    {
      Map filter1 = new HashMap();
      filter1.put("userXXid_i_eq", String.valueOf(user.getId()));
      filter1.put("fileId_i_eq", String.valueOf(
        workflowFileinbox.getWorkflowFile().getId()));
      filter1.put("stepId_i_eq", String.valueOf(
        workflowFileinbox.getWorkflowStep().getId()));
      filter1.put("signField_s_eq", signField);
      WorkflowFileopinion workflowFileopinion = this.workflowFileinboxManager
        .findWorkflowFileopinion(filter1);
      if (workflowFileopinion != null) {
        mav.addObject("opinion", 
          workflowFileopinion.getOpinion() == null ? "" : 
          workflowFileopinion.getOpinion());
      } else {
        mav.addObject("opinion", "");
      }
    }
    else
    {
      Map filter1 = new HashMap();
      filter1.put("userXXid_i_eq", String.valueOf(user.getId()));
      filter1.put("fileId_i_eq", String.valueOf(
        workflowFileinbox.getWorkflowFile().getId()));
      filter1.put("stepId_i_eq", String.valueOf(
        workflowFileinbox.getWorkflowStep().getId()));
      filter1.put("signField_s_eq", signField);
      filter1.put("approve_i_eq", "1");
      
      WorkflowFileopinion workflowFileopinion = this.workflowFileinboxManager
        .findWorkflowFileopinion(filter1);
      if (workflowFileopinion != null) {
        mav.addObject("opinion", 
          workflowFileopinion.getOpinion() == null ? "" : 
          workflowFileopinion.getOpinion());
      } else {
        mav.addObject("opinion", "");
      }
    }
    return mav;
  }
  
  public ModelAndView saveOpinion(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    String opinion = request.getParameter("opinion");
    
    String signField = request.getParameter("signField");
    
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_opinion.jsp");
    
    Map filter = new HashMap();
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    filter.put("userId_i_eq", String.valueOf(user.getId()));
    
    mav.addObject("workflowShortopinions", 
      this.workflowShortopinionManager.findWorkflowShortopinion(filter));
    mav.addObject("workflowFileinbox", workflowFileinbox);
    mav.addObject("signField", signField);
    
    this.workflowFileinboxManager.saveOpinion(workflowFileinbox, opinion, 
      signField);
    
    saveMessage(request, 
      getMessage(request, "WorkflowFileinboxManagerController_label51", "处理意见成功！"));
    
    mav.addObject("success", "1");
    
    return mav;
  }
  
  public void saveOpinion(Integer inboxId, String signField, String opinion)
    throws Exception
  {
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    this.workflowFileinboxManager.saveOpinion(workflowFileinbox, opinion, 
      signField);
  }
  
  public ModelAndView saveOpinionx(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    
    Integer opinion = new Integer(request.getParameter("opinion"));
    
    String signField = request.getParameter("signField");
    
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + inboxId);
    
    WorkflowShortopinion workflowShortopinion = this.workflowShortopinionManager
      .getWorkflowShortopinion(opinion);
    
    this.workflowFileinboxManager.saveOpinion(workflowFileinbox, 
      workflowShortopinion.getName(), signField);
    mav.addObject("opinion", opinion);
    return mav;
  }
  
  public ModelAndView openOpinion(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_dicts.jsp");
    
    Integer dictID = Integer.valueOf(ServletRequestUtils.getIntParameter(request, "dictid", 0));
    if (dictID.intValue() != 0)
    {
      WorkflowDicts workflowDicts = this.workflowDictsManager
        .getWorkflowDicts(dictID);
      mav.addObject("workflowDicts", workflowDicts.getDisplayoptions());
    }
    return mav;
  }
  
  public ModelAndView openTreeDicts(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_treedicts.jsp");
    
    int dictId = ServletRequestUtils.getIntParameter(request, "dictid", 0);
    SystemDictionary sd = null;
    try
    {
      sd = this.systemDictionaryManager.getSystemDictionary(Integer.valueOf(dictId));
    }
    catch (Exception e)
    {
      this.logger.info(e.getMessage());
    }
    String searchName = ServletRequestUtils.getStringParameter(request, 
      "searchName", "");
    Map<String, String> map = new HashMap();
    if (sd != null)
    {
      if (("1".equals(sd.getType())) || (sd.getType() == null))
      {
        if ((searchName != null) && (!"".equals(searchName)))
        {
          String sql = "select dic.id,dic.chinese_name chineseName,dic.full_name fullName  from system_dictionary dic\twhere dic.long_codes like '" + 
            sd.getLongCodes() + "%' and " + 
            "dic.chinese_name like '%" + searchName + "%' " + 
            "and not exists (" + 
            "\tselect id from system_dictionary dd where dd.parent_id = dic.id" + 
            ") order by serial";
          
          List list = this.jdbcTemplate.queryForList(sql);
          
          mav.addObject("systemDictionarys", list);
          mav.addObject("rootId", "0");
        }
        mav.addObject("sd", sd);
      }
      else
      {
        String fieldname = ServletRequestUtils.getStringParameter(request, "fieldname", "");
        String supervalue = ServletRequestUtils.getStringParameter(request, "supervalue", "");
        String treeType = ServletRequestUtils.getStringParameter(request, "treeType", "");
        String workflowId = ServletRequestUtils.getStringParameter(request, "workflowId", "");
        mav.addObject("treeType", sd.getType());
        String viewName = "";
        switch (sd.getType().charAt(0))
        {
        case '2': 
          viewName = 
          

            "redirect:/modules/security/dtree.do?method=list&openwin=true&formName=workflowFileinbox&&supname=showText_" + fieldname + "&superior=" + fieldname + (treeType.equals("treeopenx") ? "&selected=99" : "&selected=1") + "&supervalue=" + supervalue;
          break;
        case '3': 
          viewName = 
          

            "redirect:/modules/security/userTree.do?method=list&openwin=true&op=1&formName=workflowFileinbox&supname=showText_" + fieldname + "&superior=" + fieldname + (treeType.equals("treeopenx") ? "&selected=999" : "&selected=1") + "&supervalue=" + supervalue;
          break;
        case '4': 
          viewName = 
          

            "/modules/security/dtree.do?method=positionList&openwin=true&op=init&formName=workflowFileinbox&supname=showText_" + fieldname + "&superior=" + fieldname + "&workflow_id=" + workflowId + (treeType.equals("treeopenx") ? "&selected=99" : "&selected=1") + "&supervalue=" + supervalue;
        }
        mav.setViewName(viewName);
      }
    }
    else
    {
      map.put("id_i_eq", "0");
      Map orderFilter = new HashMap();
      orderFilter.put("serial", "asc");
      mav.addObject("systemDictionarys", this.systemDictionaryManager.findSystemDictionary(map, orderFilter));
      mav.addObject("rootId", "0");
    }
    return mav;
  }
  
  public ModelAndView ajaxOpinion(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    UserSession userSession = (UserSession)request.getSession().getAttribute(org.springside.core.Constants.USER_IN_SESSION);
    Integer id = new Integer(request.getParameter("id"));
    
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(id);
    

    String command = request.getParameter("command");
    String signField = request.getParameter("signField");
    signField = signField.replace("str", "");
    String optionvalue = request.getParameter("optionvalue");
    if (optionvalue == null) {
      optionvalue = "";
    }
    if ("saveOpinionx".equals(command))
    {
      WorkflowShortopinion workflowShortopinion = this.workflowShortopinionManager
        .getWorkflowShortopinion(new Integer(optionvalue));
      this.workflowFileinboxManager.saveMultiOpinion(workflowFileinbox, 
        workflowShortopinion.getName(), signField);
      
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(
        this.workflowFileinboxManager.getAllOpinion(workflowFileinbox, 
        signField));
      response.getWriter().flush();
    }
    else if ("saveOpinion".equals(command))
    {
      this.workflowFileinboxManager.saveMultiOpinion(workflowFileinbox, 
        optionvalue, signField);
      
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(
        this.workflowFileinboxManager.getAllOpinion(workflowFileinbox, 
        signField));
      response.getWriter().flush();
    }
    else if (!"saveSign".equals(command))
    {
      if ("resetOpion".equals(command))
      {
        Integer fileId = workflowFileinbox.getWorkflowFile().getId();
        Integer stepId = workflowFileinbox.getWorkflowStep().getId();
        if (!"add".equals(org.springside.core.Constants.WORKFLOW_OPINION_MODE))
        {
          this.workflowFileinboxManager.removeInvalidOpinion(fileId, signField, stepId, userSession.getId());
        }
        else
        {
          WorkflowFileopinion workflowFileopinion = new WorkflowFileopinion();
          workflowFileopinion.setFileId(fileId);
          workflowFileopinion.setStepId(stepId);
          User user = new User();
          user.setId(userSession.getId());
          workflowFileopinion.setUser(user);
          workflowFileopinion.setSignField(signField);
          this.workflowShortopinionManager.removeAjaxOpinion(workflowFileopinion);
        }
        String resetOpion = this.workflowFileinboxManager.getAllOpinion(workflowFileinbox, signField);
        if (resetOpion.indexOf("--") == -1) {
          resetOpion = "";
        }
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(resetOpion);
      }
      else if ("resetAjaxOpion".equals(command))
      {
        Integer fileId = workflowFileinbox.getWorkflowFile().getId();
        Integer stepId = workflowFileinbox.getWorkflowStep().getId();
        Map map = new HashMap();
        map.put("fileId_i_eq", fileId);
        map.put("stepId_i_eq", stepId);
        map.put("signField_s_eq", signField);
        map.put("userXXid_i_eq", userSession.getId());
        map.put("approve_i_eq", "1");
        WorkflowFileopinion workflowFileopinion = this.workflowFileinboxManager.findWorkflowFileopinion(map);
        if (workflowFileopinion != null)
        {
          if (!"add".equals(org.springside.core.Constants.WORKFLOW_OPINION_MODE)) {
            this.workflowFileinboxManager.removeInvalidOpinion(fileId, signField, stepId, userSession.getId());
          } else {
            this.workflowShortopinionManager.removeAjaxOpinion(workflowFileopinion);
          }
        }
        else if (!"add".equals(org.springside.core.Constants.WORKFLOW_OPINION_MODE)) {
          this.workflowFileinboxManager.removeInvalidOpinion(fileId, signField, stepId, userSession.getId());
        }
        String str1 = this.workflowFileinboxManager.getAllOpinion(workflowFileinbox, signField);
      }
    }
    return null;
  }
  
  public ModelAndView ajaxUpdate(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    UserSession userSession = (UserSession)request.getSession()
      .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
    User user = this.userManager.getUser(userSession.getId());
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(inboxId);
    int transId = ServletRequestUtils.getIntParameter(request, "transId", 0);
    int isspecial = ServletRequestUtils.getIntParameter(request, "isspecial", 0);
    String retString = "success@";
    if (isspecial != 3)
    {
      Map ajaxopinionMap = WebUtils.getParametersStartingWith(request, 
        "ajaxopinion_");
      

      Set keys1 = ajaxopinionMap.keySet();
      for (Object key : keys1)
      {
        String myKey = (String)key;
        String value = String.valueOf(ajaxopinionMap.get(myKey));
        String opinionStr = request.getParameter(myKey);
        String blankOpinion = ServletRequestUtils.getStringParameter(request, 
          "blankOpinion", "");
        if (opinionStr == null) {
          opinionStr = "";
        }
        if (opinionStr.equals(blankOpinion)) {
          opinionStr = "";
        }
        if ("1".equals(value)) {
          this.workflowFileinboxManager.saveAjaxOpinion(workflowFileinbox, 
            opinionStr, myKey.replace("str", ""));
        }
      }
      response.reset();
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(retString);
    }
    return null;
  }
  
  public ModelAndView ajaxSignature(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    try
    {
      Integer inboxId = new Integer(request.getParameter("inboxId"));
      
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(inboxId);
      
      Integer signId = new Integer(request.getParameter("signId"));
      
      WorkflowSignature workflowSignature = this.workflowSignatureManager
        .getWorkflowSignature(signId);
      
      String signField = request.getParameter("signField");
      
      String password = request.getParameter("password");
      
      PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
      if (workflowSignature.getPassword().equals(
        passwordEncoder.encodePassword(password, null)))
      {
        this.workflowFileinboxManager.saveSignature(workflowFileinbox, 
          workflowSignature, signField);
        
        response.setCharacterEncoding("UTF-8");
        

        response.getWriter().write(
          this.workflowFileinboxManager.getAllSign(workflowFileinbox, 
          signField));
      }
      else
      {
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(
          getMessage(request, 
          "WorkflowFileinboxManagerController_label48", 
          "签名签章密码不正确，签名不成功！"));
      }
    }
    catch (Exception e)
    {
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(
        getMessage(request, 
        "WorkflowFileinboxManagerController_label52", 
        "传递参数不正确，系统发生业务逻辑错误，签名不成功！"));
    }
    return null;
  }
  
  public void canDefaultSign(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String userid = request.getParameter("userid");
    Map map = new HashMap();
    map.put("userId_i_eq", Integer.valueOf(Integer.parseInt(userid)));
    map.put("status_i_eq", Integer.valueOf(1));
    List<WorkflowSignature> workflowSignatures = this.workflowSignatureManager.findWorkflowSignature(map);
    response.setContentType("text/plain;charset=UTF-8");
    Writer writer = response.getWriter();
    StringBuilder sb = new StringBuilder();
    PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
    if (workflowSignatures.size() == 0)
    {
      sb.append("{\"type\":\"0\",\"password\":\"-1\"}");
    }
    else if (workflowSignatures.size() == 1)
    {
      WorkflowSignature workflowSignature = (WorkflowSignature)workflowSignatures.get(0);
      if (workflowSignature.getPassword().equals(passwordEncoder.encodePassword("", null))) {
        sb.append("{\"type\":\"1\",\"password\":\"0\",\"signid\":\"" + workflowSignature.getId() + "\"}");
      } else {
        sb.append("{\"type\":\"1\",\"password\":\"1\"}");
      }
    }
    else
    {
      WorkflowSignature workflowSignature = null;
      for (int i = 0; i < workflowSignatures.size(); i++)
      {
        WorkflowSignature WSignature = (WorkflowSignature)workflowSignatures.get(i);
        if ((StringUtils.isNotEmpty(WSignature.getDefaultsign())) && (WSignature.getDefaultsign().equals("1")))
        {
          workflowSignature = WSignature;
          break;
        }
      }
      if (workflowSignature == null) {
        workflowSignature = (WorkflowSignature)workflowSignatures.get(0);
      }
      if (workflowSignature.getPassword().equals(passwordEncoder.encodePassword("", null))) {
        sb.append("{\"type\":\"2\",\"password\":\"0\",\"signid\":\"" + workflowSignature.getId() + "\"}");
      } else {
        sb.append("{\"type\":\"2\",\"password\":\"1\"}");
      }
    }
    writer.write(sb.toString());
  }
  
  public ModelAndView ajaxRemoveSignature(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    try
    {
      Integer sid = Integer.valueOf(ServletRequestUtils.getIntParameter(request, "sId", 0));
      this.workflowFileinboxManager.removeworkflowFilesign(sid);
      
      Integer inboxId = new Integer(request.getParameter("inboxId"));
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(inboxId);
      
      String signField = request.getParameter("signField");
      
      response.setCharacterEncoding("UTF-8");
      

      response.getWriter().write(
        this.workflowFileinboxManager.getAllSign(workflowFileinbox, 
        signField));
    }
    catch (Exception e)
    {
      response.setCharacterEncoding("UTF-8");
    }
    return null;
  }
  
  public ModelAndView validateSignaturePassword(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    try
    {
      Integer inboxId = new Integer(request.getParameter("inboxId"));
      
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(inboxId);
      
      Integer signId = new Integer(request.getParameter("signId"));
      
      WorkflowSignature workflowSignature = this.workflowSignatureManager
        .getWorkflowSignature(signId);
      
      String signField = request.getParameter("signField");
      
      String password = request.getParameter("password");
      
      PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
      if (workflowSignature.getPassword().equals(
        passwordEncoder.encodePassword(password, null)))
      {
        response.getWriter().write("ok");
      }
      else
      {
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(
          getMessage(request, 
          "WorkflowFileinboxManagerController_label48", 
          "签名签章密码不正确，签名不成功！"));
      }
    }
    catch (Exception e)
    {
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(
        getMessage(request, 
        "WorkflowFileinboxManagerController_label52", 
        "传递参数不正确，系统发生业务逻辑错误，签名不成功！"));
    }
    return null;
  }
  
  public ModelAndView ajaxGetNewFileno(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    try
    {
      Integer inboxId = new Integer(request.getParameter("inboxId"));
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(inboxId);
      WorkflowFileno workflowFileno = this.workflowFileinboxManager
        .saveFileno(workflowFileinbox);
      if (workflowFileno != null)
      {
        String[] fileno = workflowFileno.getFilenoLast().split("@");
        workflowFileinbox.getWorkflowFile().setFileno(
          fileno[0].trim() + fileno[1].trim() + fileno[2].trim());
        this.workflowFileinboxManager.saveWorkflowFileinbox(
          workflowFileinbox, false, false);
        response.setCharacterEncoding("UTF-8");
        
        response.getWriter().write(
          "success@" + workflowFileno.getFilenoLast());
      }
      else
      {
        response.setCharacterEncoding("UTF-8");
        
        response.getWriter().write(
          getMessage(request, 
          "WorkflowFileinboxManagerController_label50", 
          "表单中用于产生文件编号的数据不完善，暂时不能产生编号！"));
      }
    }
    catch (Exception e)
    {
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(
        getMessage(request, 
        "WorkflowFileinboxManagerController_label52", 
        "传递参数不正确，系统发生业务逻辑错误，签名不成功！"));
    }
    return null;
  }
  
  public ModelAndView saveasfrom(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String id = request.getParameter("id");
    
    String urlStr = "http://127.0.0.1:" + 
      request.getLocalPort() + 
      request.getContextPath() + 
      "/workflowArchive.do?method=archive&openwin=true&process=false&id=" + 
      
      StrUtils.getEncString(id);
    String fileName = DateUtil.getCurrentDateTime() + 
      Math.abs(Math.round(Math.random() * 10000.0D));
    String filePath = "/workflow/temporary/" + fileName;
    FileUtil.writeHttpFile(urlStr, filePath);
    if (StorageUtil.exists("/workflow/temporary/" + fileName))
    {
      response.setContentType("text/html;charset=UTF-8");
      response.setContentLength(
        (int)StorageUtil.getSize("/workflow/temporary/" + fileName));
      
      String s = "/workflow/temporary/" + fileName;
      
      response.setHeader("Content-Disposition", "attachment; filename=" + 
        new String(s.getBytes("GBK"), "ISO-8859-1") + ".html");
      StorageUtil.download("/workflow/temporary/" + fileName, 
        response.getOutputStream());
      StorageUtil.delete("/workflow/temporary/" + fileName);
    }
    return null;
  }
  
  public ModelAndView ajaxAdjustFileno(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    try
    {
      Integer inboxId = new Integer(request.getParameter("inboxId"));
      





















      String fileno1 = request.getParameter("fileno1");
      if (fileno1 == null) {
        fileno1 = "";
      }
      Integer fileno2 = new Integer(request.getParameter("fileno2"));
      String fileno3 = request.getParameter("fileno3");
      if (fileno3 == null) {
        fileno3 = "";
      }
      WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
        .getWorkflowFileinbox(inboxId);
      
      WorkflowFileno workflowFileno = this.workflowFileinboxManager
        .getWorkflowFileno(workflowFileinbox);
      if (workflowFileno != null)
      {
        workflowFileno = this.workflowFileinboxManager.saveFilenoAdjust(
          workflowFileinbox, workflowFileno, fileno2);
        String[] fileno = workflowFileno.getFilenoLast().split("@");
        workflowFileinbox.getWorkflowFile().setFileno(
          fileno[0].trim() + fileno[1].trim() + fileno[2].trim());
        this.workflowFileinboxManager.saveWorkflowFileinbox(
          workflowFileinbox, false, false);
        response.setCharacterEncoding("UTF-8");
        
        response.getWriter().write(
          "success@" + workflowFileno.getFilenoLast());
      }
      else
      {
        response.setCharacterEncoding("UTF-8");
        response.getWriter().write(
          getMessage(request, 
          "WorkflowFileinboxManagerController_label50", 
          "表单中用于产生文件编号的数据不完善，暂时不能产生编号！"));
      }
    }
    catch (Exception e)
    {
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write(
        getMessage(request, 
        "WorkflowFileinboxManagerController_label52", 
        "传递参数不正确，系统发生业务逻辑错误，签名不成功！"));
    }
    return null;
  }
  
  private String getWSSPUrl(HttpServletRequest request)
  {
    String linkUrl = null;
    UserSession userLogin = (UserSession)request.getSession()
      .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
    User user = this.userManager.getUser(userLogin.getId());
    Set<Role> roles = user.getRoles();
    for (Role role : roles)
    {
      boolean flag = false;
      Set<Permission> perms = role.getPermissions();
      for (Permission perm : perms) {
        if (perm.getName().equals("AUTH_MODULES_GWJH_WSSP"))
        {
          String confProperties = "/gwjh/WSSPConf.properties";
          File f = StorageUtil.getFile(confProperties);
          
          Properties p = new Properties();
          try
          {
            p.load(new FileInputStream(f));
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
          try
          {
            linkUrl = 
            



















              "http://" + p.getProperty("hostip", "") + ":" + p.getProperty("hostport", "80") + "/exap/ProvinceOAExchange?" + "userid=" + URLEncoder.encode(p.getProperty("userid", ""), "UTF-8") + "&password=" + URLEncoder.encode(p.getProperty("password", ""), "UTF-8") + "&orguuid=" + URLEncoder.encode(p.getProperty("orguuid", ""), "UTF-8") + "&orgname=" + URLEncoder.encode(p.getProperty("orgname", ""), "UTF-8") + "&sysId=" + URLEncoder.encode(p.getProperty("sysId", ""), "UTF-8") + "&personName=" + URLEncoder.encode(p.getProperty("personName", 
              ""), "UTF-8");
          }
          catch (UnsupportedEncodingException e)
          {
            e.printStackTrace();
          }
          flag = true;
          break;
        }
      }
      if (flag) {
        break;
      }
    }
    return linkUrl;
  }
  
  public ModelAndView attentionAudit(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    String view = ServletRequestUtils.getStringParameter(request, "view", "");
    UserSession user = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(user, String.valueOf(inboxId))) {
      createPermException(request, "协同审批->待办公文->关注审批", null);
    }
    User users = this.userManager.getUser(user.getId());
    






    ModelAndView mav = new ModelAndView(
      "redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
      inboxId);
    
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(id);
    workflowFile.getAttentionUsers().add(users);
    this.workflowFileManager.saveWorkflowFile(workflowFile);
    if (view.equals("show")) {
      mav.setViewName("/modules/workflow/workflowFileinbox.do?method=show&id=" + inboxId);
    }
    saveMessage(request, "关注审批成功！");
    return mav;
  }
  
  public ModelAndView attentionCancel(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    String view = ServletRequestUtils.getStringParameter(request, "view", "");
    
    UserSession user = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInboxAllStatus(user, String.valueOf(inboxId))) {
      createPermException(request, "协同审批->待办公文->取消关注", null);
    }
    User users = this.userManager.getUser(user.getId());
    







    ModelAndView mav = new ModelAndView(
      "redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
      inboxId);
    
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(id);
    if (workflowFile.getAttentionUsers().contains(users))
    {
      workflowFile.getAttentionUsers().remove(users);
      this.workflowFileManager.saveWorkflowFile(workflowFile);
    }
    if (view.equals("show"))
    {
      mav.setViewName("/modules/workflow/workflowFileinbox.do?method=show&id=" + 
        inboxId);
      




      mav
        .setViewName("/modules/workflow/workflowFileinbox.do?method=show&id=" + 
        inboxId);
      
      mav.addObject("msg", 
        getMessage(request, "workflowController_label2", "取消关注审批成功！"));
    }
    saveMessage(request, 
      getMessage(request, "workflowController_label2", "取消关注审批成功！"));
    return mav;
  }
  
  public ModelAndView AjaxAttentionAudit(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    
    UserSession user = getUserSession(request);
    
    User users = this.userManager.getUser(user.getId());
    
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(id);
    workflowFile.getAttentionUsers().add(users);
    this.workflowFileManager.saveWorkflowFile(workflowFile);
    response.setContentType("text/plain;charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    Writer writer = response.getWriter();
    writer.write("true");
    writer.close();
    return null;
  }
  
  public ModelAndView AjaxAttentionCancel(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer id = new Integer(request.getParameter("id"));
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    String view = ServletRequestUtils.getStringParameter(request, "view", "");
    
    UserSession user = getUserSession(request);
    User users = this.userManager.getUser(user.getId());
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(id);
    if (workflowFile.getAttentionUsers().contains(users))
    {
      workflowFile.getAttentionUsers().remove(users);
      this.workflowFileManager.saveWorkflowFile(workflowFile);
    }
    response.setContentType("text/plain;charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    Writer writer = response.getWriter();
    writer.write("true");
    writer.close();
    return null;
  }
  
  public ModelAndView design(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflow_designer.jsp");
    

    String oaLanguage = getRequestLanguage(request);
    if (("zh_cn".equals(oaLanguage)) || ("zh_CN".equals(oaLanguage))) {
      oaLanguage = "zh_CN";
    } else if (("en_US".equals(oaLanguage)) || ("en_us".equals(oaLanguage))) {
      oaLanguage = "en_US";
    } else if (("zh_TW".equals(oaLanguage)) || ("zh_tw".equals(oaLanguage)) || ("zh_HK".equals(oaLanguage)) || ("zh_hk".equals(oaLanguage))) {
      oaLanguage = "ja_JP";
    } else {
      oaLanguage = "zh_CN";
    }
    mav.addObject("oaLanguage", oaLanguage);
    












    return mav;
  }
  
  public ModelAndView getMemberString(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    int stepId = ServletRequestUtils.getIntParameter(request, "stepId", -1);
    int inboxId = ServletRequestUtils.getIntParameter(request, "inboxId", -1);
    List nextStepList = new ArrayList();
    WorkflowStep workflowStep = this.workflowStepManager.getWorkflowStep(Integer.valueOf(stepId));
    nextStepList.add(workflowStep);
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
      .getWorkflowFileinbox(Integer.valueOf(inboxId));
    Map map = this.workflowFileinboxManager.getMembers(nextStepList, 
      workflowFileinbox, 0);
    String retString = (String)map.get(new Integer(stepId));
    if (workflowStep.getDays() != null) {
      retString = retString + "|" + workflowStep.getDays();
    } else {
      retString = retString + "|0";
    }
    response.setContentType("text/plain;charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    Writer writer = response.getWriter();
    writer.write(retString);
    writer.close();
    return null;
  }
  
  public ModelAndView ajaxgetStepUserString(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String fid = request.getParameter("fid");
    String stepUser = this.workflowFileinboxManager.getStepUserString(fid);
    response.setContentType("text/plain;charset=UTF-8");
    Writer writer = response.getWriter();
    writer.write(stepUser);
    
    return null;
  }
  
  public ModelAndView alreadyFilePortlet(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String count = request.getParameter("count");
    if ((count == null) || ("".equals(count))) {
      count = "5";
    }
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    
    ModelAndView mav = new ModelAndView("/themes/" + user.getTheme() + 
      "/home/workflow_portal_alreadyfile.jsp");
    
    mav.addObject("workflowFileinboxs", 
      this.workflowFileinboxManager
      .findWorkflowFileinboxPortal_alreadyFile(user, new Integer(count)));
    
    return mav;
  }
  
  public ModelAndView ajaxSubmitUpdate(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=");
    try
    {
      onSave(request, response, mav, false, true);
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write("success");
    }
    catch (Exception e)
    {
      response.setCharacterEncoding("UTF-8");
      response.getWriter().write("failed");
    }
    return null;
  }
  
  public ModelAndView ajaxCompareNowDate(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    response.setContentType("text/plain;charset=UTF-8");
    Writer writer = response.getWriter();
    
    Date nowDate = new Date();
    






















    String stepdate = request.getParameter("stepdate");
    String compareDate = request.getParameter("compareDate");
    
    String flag = request.getParameter("flag");
    
    String id = request.getParameter("id");
    try
    {
      if ("file".equals(flag))
      {
        Map filter = new HashMap();
        filter.put("workflowFileXXid_i_eq", id);
        
        filter.put("issent_i_in", "1,2");
        List<WorkflowFileinbox> workflowFileinboxList = this.workflowFileinboxManager
          .findWorkflowFileinbox(filter);
        for (WorkflowFileinbox box : workflowFileinboxList) {
          if ((box.getWorkflowStep().getDays() != null) && 
            (box.getWorkflowStep().getDays().intValue() != 0))
          {
            int internal = box.getWorkflowStep().getDays().intValue() * 60;
            
            Date termDate = this.systemWorkhourManager.getBusinessTime(
              box.getUser(), box.getStartdate(), Integer.valueOf(internal));
            if (nowDate.compareTo(termDate) > 0)
            {
              writer.write("true");
              writer.close();
              return null;
            }
          }
          else if ((box.getWishdate() != null) && 
            (nowDate.compareTo(box.getWishdate()) > 0))
          {
            writer.write("true");
            writer.close();
            return null;
          }
        }
      }
      else if ("inbox".equals(flag))
      {
        WorkflowFileinbox inbox = this.workflowFileinboxManager
          .getWorkflowFileinbox(new Integer(id));
        if ((inbox.getIssent().intValue() != 1) && 
          (inbox.getIssent().intValue() != 2))
        {
          writer.write("false");
          writer.close();
          return null;
        }
        if ((stepdate != null) && (!"".equals(stepdate)) && 
          (!"0".equals(stepdate)))
        {
          int internal = Integer.parseInt(stepdate) * 60;
          
          Date termDate = this.systemWorkhourManager.getBusinessTime(
            inbox.getUser(), inbox.getStartdate(), Integer.valueOf(internal));
          if (nowDate.compareTo(termDate) > 0)
          {
            writer.write("true");
            writer.close();
            return null;
          }
        }
        else
        {
          if ((compareDate == null) || ("".equals(compareDate)))
          {
            writer.write("false");
            writer.close();
            return null;
          }
          SimpleDateFormat sd = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss");
          
          Date newDate = sd.parse(compareDate);
          if (nowDate.compareTo(newDate) > 0)
          {
            writer.write("true");
            writer.close();
            return null;
          }
        }
      }
    }
    catch (Exception e)
    {
      writer.write("false");
      writer.close();
      return null;
    }
    writer.write("false");
    writer.close();
    return null;
  }
  
  public boolean getCanDraft(String fileId, String inboxId, UserSession user)
  {
    boolean flag = false;
    if (StringUtils.isBlank(fileId)) {
      return flag;
    }
    if (Integer.valueOf(fileId).intValue() != 0)
    {
      if (StringUtils.isBlank(inboxId))
      {
        WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(Integer.valueOf(fileId));
        if ((workflowFile != null) && (workflowFile.getFlowFlag().intValue() != 0))
        {
          flag = this.workflowManager.getIsObservers(workflowFile.getWorkflow().getId(), user);
          if (!flag) {
            flag = this.workflowManager.getIsSupervisor(workflowFile.getWorkflow().getId(), user);
          }
          if (!flag) {
            flag = this.workflowFlowRightManager.getWorkflowPerm(workflowFile.getWorkflow().getId(), user.getId());
          }
        }
      }
      else if (this.workflowFileinboxManager.getHavePermOfInboxAllStatus(user, inboxId))
      {
        WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(Integer.valueOf(inboxId));
        if ((1 != workflowFileinbox.getIssent().intValue()) && (workflowFileinbox.getIsspecial().intValue() == 0)) {
          flag = true;
        }
      }
      Integer ParentflowId = this.workflowFileManager.getWorkflowFile(Integer.valueOf(fileId)).getWorkflow().getParentId();
      if (this.workflowFileManager.isArchiveMan(ParentflowId, user)) {
        flag = true;
      }
    }
    else if (StringUtils.isBlank(inboxId))
    {
      flag = true;
    }
    return flag;
  }
  
  private void onCreateNew(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
    throws Exception
  {
    Integer flowId = new Integer(request.getParameter("flowId"));
    
    String returnView = "";
    UserSession user = (UserSession)request.getSession().getAttribute(
      org.springside.core.Constants.USER_IN_SESSION);
    



    String fromId = request.getParameter("fromId");
    String inboxId = request.getParameter("inboxId");
    if (!this.workflowManager.getCanOperate(flowId, user)) {
      createPermException(request, "协同审批->新建公文", null);
    }
    WorkflowFileinbox workflowFileinbox = null;
    try
    {
      workflowFileinbox = this.workflowFileinboxManager.init(flowId, user);
    }
    catch (Exception e)
    {
      mav.setViewName(this.listView);
      return;
    }
    if (workflowFileinbox.getWorkflowStep().getName().equals("报销分摊开始"))
    {
      mav.addObject("SHOW_BAOXIAOFENTAN", "yes");
      

      Map<String, String> filter = new HashMap();
      filter.put("flowtypeId_i_eq", 
        workflowFileinbox.getWorkflow().getFlowtypeId().toString());
      List<WorkflowFlowfield> fields = this.workflowFlowfieldManager
        .findWorkflowFlowfield(filter);
      for (WorkflowFlowfield field : fields) {
        if ("报销类型".equals(field.getName()))
        {
          String fname = field.getFieldtype() + field.getDatatype() + 
            field.getFieldserial();
          mav.addObject("bxlx", fname);
        }
        else
        {
          if (",报销内容摘要,金额,备注,".contains("," + field.getName() + 
            ",")) {
            if (field.getFieldtype().equals("list"))
            {
              String fname = "listZZfieldstr" + field.getFieldserial() + 
                "ZZ";
              if ("报销内容摘要".equals(field.getName()))
              {
                mav.addObject("bxnrzy", fname); continue;
              }
              if ("金额".equals(field.getName()))
              {
                mav.addObject("je", fname); continue;
              }
              mav.addObject("bz", fname); continue;
            }
          }
          if ("合计金额".equals(field.getName()))
          {
            String fname = "fieldstr" + field.getFieldserial();
            mav.addObject("hjje", fname);
          }
          else if ("报销日期".equals(field.getName()))
          {
            ReflectUtil.setClassAttributeValue(
              workflowFileinbox.getWorkflowFile(), "fieldstr" + 
              field.getFieldserial(), 
              new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
          }
        }
      }
    }
    if (workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
      .getFilenoAuto() != null) {
      if (workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
        .getFilenoAuto().intValue() == 1) {
        try
        {
          WorkflowFileno workflowFileno = this.workflowFileinboxManager
            .saveFileno(workflowFileinbox);
          if ((workflowFileno != null) && 
            (!StringUtils.isBlank(workflowFileno.getFilenoLast())))
          {
            String[] fileno = workflowFileno.getFilenoLast().split("@");
            





            int fileNoStart = workflowFileinbox.getWorkflowFile().getWorkflowFlowtype().getFilenoStart().intValue();
            if ((workflowFileno.getFilenoValue() != null) && (fileNoStart > workflowFileno.getFilenoValue().intValue()))
            {
              String newFileNo = "";
              String format = "%03d";
              if (fileno[1] != null)
              {
                int len = fileno[1].trim().length();
                if (len > 3) {
                  format = "%0" + len + "d";
                }
              }
              try
              {
                newFileNo = String.format(format, new Object[] { Integer.valueOf(fileNoStart) });
              }
              catch (Exception e)
              {
                System.out.println("格式化起始编号异常：" + e.getMessage());
              }
              if (!StringUtils.isBlank(newFileNo))
              {
                workflowFileinbox.getWorkflowFile().setFileno(newFileNo);
                workflowFileno = this.workflowFileinboxManager.saveFileno(workflowFileinbox, Integer.valueOf(fileNoStart));
              }
            }
            else if (fileno.length == 3)
            {
              workflowFileinbox.getWorkflowFile().setFileno(
                fileno[0].trim() + fileno[1].trim() + 
                fileno[2].trim());
            }
          }
        }
        catch (BusinessException e)
        {
          this.logger.error(e);
        }
      }
    }
    if ((workflowFileinbox.getWorkflow().getIsIntegration() != null) && 
      (workflowFileinbox.getWorkflow().getIsIntegration().intValue() == 1))
    {
      String errorMsg = this.workflowIntegrationManager
        .getIntegrationData(workflowFileinbox.getWorkflowFile(), 
        workflowFileinbox.getWorkflowStep());
      if (StringUtils.isNotEmpty(errorMsg)) {
        saveMessage(request, errorMsg);
      }
    }
    this.workflowFileinboxManager.handleSystemDate(workflowFileinbox);
    this.workflowFileinboxManager.handleSystemTime(workflowFileinbox);
    mav.addObject("workflowFileinbox", workflowFileinbox);
    


    mav.addObject("workflowFile", workflowFileinbox.getWorkflowFile());
    


    String base = this.workflowFlowtypeManager.getDesignbase(
      workflowFileinbox.getWorkflow().getFlowtypeId(), "");
    


    String content = this.workflowFlowtypeManager.getDesignbaseContent(
      workflowFileinbox.getWorkflow().getFlowtypeId(), "");
    


    mav.addObject("dynamicForm", this.workflowFlowtypeManager
      .getDynamicForm(workflowFileinbox, false, user, content));
    mav.addObject("printtemplates", 
      this.workflowFlowtypeManager
      .findWordtemplateByType(workflowFileinbox.getWorkflow().getFlowtypeId(), Integer.valueOf(3)));
    if (workflowFileinbox.getWorkflow().getEditStyle().intValue() == 0) {
      returnView = this.editView;
    } else {
      returnView = "/modules/workflow/workflowFileinbox_edit_mulit.jsp";
    }
    String fromType = request.getParameter("fromType");
    
    mav.addObject("fromTypeValue", fromType);
    mav.addObject("fromIdValue", fromId);
    if ((fromId != null) && (!"0".equals(fromId))) {
      if (Integer.parseInt(fromType) < 3)
      {
        WorkflowFile workflowFile = null;
        try
        {
          workflowFile = this.workflowFileManager.getWorkflowFile(Integer.valueOf(Integer.parseInt(fromId)));
        }
        catch (Exception e)
        {
          this.logger.info("关联公文已被删除，关联ID:" + fromId);
        }
        if (workflowFile != null) {
          mav.addObject("relationFile", workflowFile);
        }
        mav.addObject("relationFileId", StrUtils.getEncString(fromId));
      }
    }
    returnView = 
      returnView + "?method=edit&flowId=" + String.valueOf(flowId) + "&isNew=true";
    mav.setViewName(returnView + "&oinboxId=" + ServletRequestUtils.getStringParameter(request, "viewId", ""));
    Object nextStepList = this.workflowFileinboxManager
      .getNextStep(workflowFileinbox);
    Map orderMap = new LinkedHashMap();
    orderMap.put("posy", "asc");
    orderMap.put("posx", "asc");
    Collections.sort((List)nextStepList, ObjectComparator.instance(orderMap));
    mav.addObject("workflowStepInfoMap", 
      this.workflowStepManager
      .findWorkflowStepInfoByFlowIdToMap(workflowFileinbox.getWorkflow().getId()));
    mav.addObject("nextSteps", nextStepList);
    mav.addObject("isFirstCreate", "yes");
    

    mav.addObject("knowledgesList", this.workflowKnowledgeManager.getWorkflowKnowledgeList(workflowFileinbox.getWorkflow().getId()));
  }
  
  private int uploadeFile(HttpServletRequest request, HttpServletResponse response, WorkflowFileinbox workflowFileinbox, ModelAndView mav)
    throws Exception
  {
    WorkflowFileattach workflowFileattach = new WorkflowFileattach();
    





















    workflowFileattach.setCheckout(Integer.valueOf(0));
    workflowFileattach.setCreatedate(DateUtil.getDate());
    workflowFileattach.setVer(Integer.valueOf(1));
    workflowFileattach.setLastver(Integer.valueOf(1));
    workflowFileattach.setWorkflowFile(workflowFileinbox.getWorkflowFile());
    workflowFileattach.setUserByUserId(workflowFileinbox.getUser());
    
    this.documentDir = 
    



      ("/workflow/document/" + DateUtil.getYearmonth(workflowFileinbox.getWorkflowFile().getSubmitdate()) + "/" + String.valueOf(workflowFileinbox.getWorkflow().getId()) + "/" + String.valueOf(workflowFileinbox.getWorkflowFile().getId()));
    String fileTitle = request.getParameter("fileTitle");
    workflowFileattach.setTitle(fileTitle);
    String fileType = request.getParameter("type");
    int type = 0;
    if ((fileType == null) || ("".equals(fileType))) {
      type = 1;
    } else {
      type = Integer.parseInt(fileType);
    }
    workflowFileattach.setType(Integer.valueOf(type));
    MultipartHttpServletRequest multipartRequest = null;
    try
    {
      multipartRequest = (MultipartHttpServletRequest)request;
    }
    catch (ClassCastException e)
    {
      this.logger.error(e);
    }
    if (multipartRequest != null)
    {
      MultipartFile multipartFile = multipartRequest
        .getFile("serverfile");
      String serverfile = "";
      String filename = "";
      String fileext = "";
      long filesize = 0L;
      if ((multipartFile != null) && 
        (StringUtils.isNotEmpty(multipartFile
        .getOriginalFilename())))
      {
        filename = ServletRequestUtils.getStringParameter(request, "uploadfilename", multipartFile.getOriginalFilename());
        filename = "V" + String.valueOf(workflowFileattach.getVer()) + 
          "_" + filename;
        serverfile = this.documentDir + "/" + DateUtil.getOnlyID();
        StorageUtil.writeFile(multipartFile.getInputStream(), 
          serverfile);
        fileext = multipartFile.getContentType();
        int pos = filename.lastIndexOf(".");
        if (filename.substring(pos + 1).equalsIgnoreCase("docx")) {
          fileext = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
        }
        if (filename.substring(pos + 1).equalsIgnoreCase("xlsx")) {
          fileext = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        }
        if (filename.substring(pos + 1).equalsIgnoreCase("pptx")) {
          fileext = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
        }
        filesize = multipartFile.getSize();
        if (filesize == 0L) {
          return -1;
        }
        workflowFileattach.setServerfile(serverfile);
        
        workflowFileattach.setFilename(filename);
        workflowFileattach.setFileext(fileext);
        workflowFileattach.setFilesize(new Integer(
          String.valueOf(filesize)));
      }
    }
    this.workflowFileattachManager.saveWorkflowFileattach(workflowFileattach, 
      true);
    saveMessage(request, getMessage(request, "common_label1", "数据") + 
      getMessage(request, "common_label2", "新增") + 
      
      getMessage(request, "common_label4", "成功") + "!");
    return 0;
  }
  
  public ModelAndView nullifyFlow(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String viewName = this.successView + "?ec_s_startdate=desc";
    ModelAndView mav = new ModelAndView(viewName);
    String type = ServletRequestUtils.getStringParameter(request, "type");
    String roleName = getMessage(request, "WorkflowFileinboxManagerController_label61", "审批人");
    if ((type != null) && (type.equals("supervisorFinish")))
    {
      roleName = getMessage(request, "WorkflowFileinboxManagerController_label62", "监控员");
      mav.setViewName("/modules/workflow/workflowFile.do?method=supervisor&ec_s_submitdate=desc");
    }
    else
    {
      onSave(request, response, mav, false, false);
    }
    Integer id = ServletRequestUtils.getIntParameter(request, "inboxId");
    Integer fileId = ServletRequestUtils.getIntParameter(request, "fileId");
    String nullifyDesc = ServletRequestUtils.getStringParameter(request, "nullifyDesc");
    
    UserSession userSession = getUserSession(request);
    if ((id != null) && (id.intValue() != 0))
    {
      WorkflowFileinbox workflowFileinbox1 = this.workflowFileinboxManager.getWorkflowFileinbox(id);
      this.workflowFileinboxManager.saveApproveOpinion(workflowFileinbox1);
    }
    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    if (!StringUtils.isBlank(workflowFile.getEndDesc()))
    {
      endFlowMessage(workflowFile, request);
      mav.setViewName(viewName);
      return mav;
    }
    if (workflowFile.getFlowFlag().intValue() != 5)
    {
      workflowFile.setFlowFlag(Integer.valueOf(5));
      
      workflowFile.setNullifyDesc(nullifyDesc);
      workflowFile.setNullifyUser(this.userManager.getUser(userSession.getId()));
      this.workflowFileManager.saveWorkflowFile(workflowFile);
      

      Map filter = new HashMap();
      filter.put("workflowFileXXid_i_eq", fileId);
      Map orderMap = new HashMap();
      orderMap.put("id", "desc");
      
      String catalogy = workflowFile.getWorkflow().getCatalogy();
      List<WorkflowFileinbox> inboxList = null;
      if (catalogy.equals("费用报销")) {
        inboxList = this.workflowFileinboxManager1.findWorkflowFileinbox(filter, orderMap);
      } else {
        inboxList = this.workflowFileinboxManager.findWorkflowFileinbox(filter, orderMap);
      }
      List<User> userList = new ArrayList();
      if ((inboxList != null) && (!inboxList.isEmpty()))
      {
        List<Messages> messageList = null;
        Messages message = null;
        Map messageFilter = new HashMap();
        for (WorkflowFileinbox workflowFileinbox : inboxList)
        {
          messageFilter.clear();
          messageFilter.put("entityId_i_eq", workflowFileinbox.getId());
          messageList = this.messagesManager.findMessages(messageFilter);
          if ((messageList != null) && (!messageList.isEmpty())) {
            for (Messages messages : messageList) {
              this.messagesManager.removeMessages(messages.getId());
            }
          }
          if ((!userList.contains(workflowFileinbox.getUser())) && 
            (!workflowFileinbox.getUser().getId().equals(userSession.getId()))) {
            if ((workflowFileinbox.getIssent().intValue() == 2) || (workflowFileinbox.getIssent().intValue() == 3) || (workflowFileinbox.getIssent().intValue() == 4) || (workflowFileinbox.getIssent().intValue() == 13))
            {
              Messages messages = new Messages();
              
              String title = this.workflowFileinboxManager.formatTitle(workflowFileinbox) + 
                "," + getMessage(request, "WorkflowFileinboxManagerController_label63", "已被") + 
                roleName + userSession.getName() + 
                getMessage(request, "WorkflowFileinboxManagerController_label64", "作废,作废备注") + 
                "：" + nullifyDesc + ",";
              if (catalogy.equals("费用报销")) {
                title = title + "来自[费用报销]";
              } else {
                title = title + getMessage(request, "WorkflowFileinboxManagerController_label72", "来自[公文处理]");
              }
              messages.setTitle(title);
              messages.setCreatedate(DateUtil.getDate());
              messages.setContent("“" + workflowFileinbox.getWorkflowFile().getTitle() + 
                "” " + getMessage(request, "WorkflowFileinboxManagerController_label63", "已被") + 
                roleName + userSession.getName() + 
                getMessage(request, "WorkflowFileinboxManagerController_label64", "作废,作废备注") + "：" + nullifyDesc);
              messages.setFromId(Integer.valueOf(0));
              messages.setIsread(Integer.valueOf(0));
              messages.setSourceId(Integer.valueOf(2));
              messages.setType(Integer.valueOf(1));
              messages.setPri(Integer.valueOf(2));
              messages.setUserByUserId(workflowFileinbox.getUser());
              messages.setUserByFromuserId(this.userManager.getUser(userSession.getId()));
              messages.setAttachs("");
              messages.setUrl("");
              messages.setEntityId(workflowFileinbox.getId());
              messages.setEntityClass(
                workflowFileinbox.getClass().getName());
              try
              {
                this.messagesManager.saveMessages(messages, 0);
                userList.add(workflowFileinbox.getUser());
              }
              catch (BusinessException e)
              {
                e.printStackTrace();
              }
            }
          }
          if ((workflowFileinbox.getIssent().intValue() != 3) && (workflowFileinbox.getIssent().intValue() != 13)) {
            workflowFileinbox.setIssent(Integer.valueOf(workflowFileinbox.getIssent().intValue() + 100));
          }
          this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox);
        }
      }
      WorkflowFileinbox fileInbox = null;
      if (id == null)
      {
        if ((inboxList != null) && (!inboxList.isEmpty())) {
          fileInbox = (WorkflowFileinbox)inboxList.get(0);
        }
      }
      else {
        fileInbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
      }
      User user = this.userManager.getUser(userSession.getId());
      if (fileInbox != null) {
        this.workflowFileinboxManager.saveNullifyWorkflowFileprocess(fileInbox, user, nullifyDesc);
      }
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label65", "文件作废成功！"));
    }
    else
    {
      saveNullifyMessage(workflowFile, request);
    }
    return mav;
  }
  
  public void saveNullifyMessage(WorkflowFile workflowFile, HttpServletRequest request)
  {
    User user = workflowFile.getNullifyUser();
    String name = "";
    if (user != null) {
      name = user.getName();
    }
    saveMessage(request, 
      getMessage(request, "WorkflowFileinboxManagerController_label66", "文件已被") + 
      name + 
      getMessage(request, "WorkflowFileinboxManagerController_label67", "作废，不能再进行操作！"));
  }
  
  public void endFlowMessage(WorkflowFile workflowFile, HttpServletRequest request)
  {
    User user = workflowFile.getEndUser();
    String name = "";
    if (user != null) {
      name = user.getName();
    }
    saveMessage(request, 
      getMessage(request, "WorkflowFileinboxManagerController_label66", "文件已被") + 
      getMessage(request, "WorkflowFileinboxManagerController_label61", "审批人") + 
      name + 
      getMessage(request, "workflowFileinbox_edit_label105", "结束！").replaceAll("&nbsp;", ""));
  }
  
  public ModelAndView recoverNullifyFlow(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView("/modules/workflow/workflowFile.do?method=supervisorFinish&ec_s_submitdate=desc");
    
    Integer fileId = ServletRequestUtils.getIntParameter(request, "fileId");
    
    String recoverNullifyDesc = ServletRequestUtils.getStringParameter(request, "recoverNullifyDesc");
    UserSession userSession = getUserSession(request);
    



    WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
    if (workflowFile.getFlowFlag().intValue() == 5)
    {
      workflowFile.setFlowFlag(Integer.valueOf(2));
      
















      workflowFile.setRecoverNullifyDesc(recoverNullifyDesc);
      workflowFile.setRecoverNullifyUser(this.userManager.getUser(userSession.getId()));
      this.workflowFileManager.saveWorkflowFile(workflowFile);
      

      Map filter = new HashMap();
      filter.put("workflowFileXXid_i_eq", fileId);
      Map orderMap = new HashMap();
      orderMap.put("id", "desc");
      
      String catalogy = workflowFile.getWorkflow().getCatalogy();
      List<WorkflowFileinbox> inboxList = null;
      if (catalogy.equals("费用报销")) {
        inboxList = this.workflowFileinboxManager1.findWorkflowFileinbox(filter, orderMap);
      } else {
        inboxList = this.workflowFileinboxManager.findWorkflowFileinbox(filter, orderMap);
      }
      List<User> userList = new ArrayList();
      if ((inboxList != null) && (!inboxList.isEmpty()))
      {
        List<Messages> messageList = null;
        Map messageFilter = new HashMap();
        for (WorkflowFileinbox workflowFileinbox : inboxList)
        {
          messageFilter.clear();
          messageFilter.put("sourceId_i_eq", Integer.valueOf(2));
          messageFilter.put("entityClass_s_eq", workflowFileinbox.getClass().getName());
          messageFilter.put("entityId_i_eq", workflowFileinbox.getId());
          messageList = this.messagesManager.findMessages(messageFilter);
          if ((messageList != null) && (!messageList.isEmpty())) {
            for (Messages messages : messageList) {
              this.messagesManager.removeMessages(messages.getId());
            }
          }
          if ((!userList.contains(workflowFileinbox.getUser())) && 
            (!workflowFileinbox.getUser().getId().equals(userSession.getId()))) {
            if ((workflowFileinbox.getIssent().intValue() == 102) || (workflowFileinbox.getIssent().intValue() == 3) || (workflowFileinbox.getIssent().intValue() == 13) || (workflowFileinbox.getIssent().intValue() == 104))
            {
              Messages messages = new Messages();
              
              String title = this.workflowFileinboxManager.formatTitle(workflowFileinbox) + 
                "," + getMessage(request, "WorkflowFileinboxManagerController_label68", "已被监控员") + userSession.getName() + 
                getMessage(request, "WorkflowFileinboxManagerController_label69", "反作废,反作废备注") + "：" + recoverNullifyDesc + 
                ",";
              
              Integer sourceId = Integer.valueOf(2);
              if (catalogy.equals("费用报销"))
              {
                title = title + "来自[费用报销]";
                sourceId = Integer.valueOf(63);
              }
              else
              {
                title = title + getMessage(request, "WorkflowFileinboxManagerController_label72", "来自[公文处理]");
              }
              messages.setTitle(title);
              messages.setCreatedate(DateUtil.getDate());
              messages.setContent("“" + workflowFileinbox.getWorkflowFile().getTitle() + 
                "” " + getMessage(request, "WorkflowFileinboxManagerController_label68", "已被监控员") + 
                userSession.getName() + getMessage(request, "WorkflowFileinboxManagerController_label69", "反作废,反作废备注") + "：" + recoverNullifyDesc);
              messages.setFromId(Integer.valueOf(0));
              messages.setIsread(Integer.valueOf(0));
              messages.setSourceId(sourceId);
              messages.setType(Integer.valueOf(1));
              messages.setPri(Integer.valueOf(2));
              messages.setUserByUserId(workflowFileinbox.getUser());
              messages.setUserByFromuserId(this.userManager.getUser(userSession.getId()));
              messages.setAttachs("");
              messages.setUrl("");
              messages.setEntityId(workflowFileinbox.getId());
              messages.setEntityClass(
                workflowFileinbox.getClass().getName());
              try
              {
                this.messagesManager.saveMessages(messages, 0);
                userList.add(workflowFileinbox.getUser());
              }
              catch (BusinessException e)
              {
                e.printStackTrace();
              }
            }
          }
          if ((workflowFileinbox.getIssent().intValue() != 3) && (workflowFileinbox.getIssent().intValue() != 13)) {
            workflowFileinbox.setIssent(Integer.valueOf(workflowFileinbox.getIssent().intValue() - 100));
          }
          this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox);
        }
      }
      User user = this.userManager.getUser(userSession.getId());
      WorkflowFileinbox fileInbox = null;
      if ((inboxList != null) && (!inboxList.isEmpty())) {
        fileInbox = (WorkflowFileinbox)inboxList.get(0);
      }
      if (fileInbox != null) {
        this.workflowFileinboxManager.saveRecoverNullifyWorkflowFileprocess(fileInbox, user, recoverNullifyDesc);
      }
      saveMessage(request, getMessage(request, "WorkflowFileinboxManagerController_label70", "文件反作废成功！"));
    }
    else
    {
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label66", "文件已被") + 
        workflowFile.getRecoverNullifyUser().getName() + 
        getMessage(request, "WorkflowFileinboxManagerController_label71", "反作废，不能再进行反作废操作！"));
    }
    return mav;
  }
  
  public ModelAndView endFlow(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView(this.successView);
    

    onSave(request, response, mav, false, false);
    

    Integer id = ServletRequestUtils.getIntParameter(request, "inboxId");
    Integer fileId = ServletRequestUtils.getIntParameter(request, "fileId");
    Integer flowId = ServletRequestUtils.getIntParameter(request, "flowId");
    
    String endDesc = ServletRequestUtils.getStringParameter(request, "endDesc");
    System.out.println("endDesc=" + endDesc);
    


    WorkflowFileinbox fileinbox = null;
    try
    {
      fileinbox = this.workflowFileinboxManager.getWorkflowFileinbox(id);
      this.workflowFileinboxManager.saveApproveOpinion(fileinbox);
      if (fileinbox.getWorkflowFile().getFlowFlag().intValue() == 1)
      {
        endFlowMessage(fileinbox.getWorkflowFile(), request);
        mav.setViewName(this.successView);
        return mav;
      }
    }
    catch (ObjectRetrievalFailureException e)
    {
      Map filterFileinbox = new HashMap();
      filterFileinbox.put("workflowXXid_i_eq", flowId);
      filterFileinbox.put("workflowFileXXid_i_eq", fileId);
      filterFileinbox.put("workflowStepXXsteptypeId_i_eq", Integer.valueOf(8));
      

      List<WorkflowFileinbox> fileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(filterFileinbox);
      if (fileinboxList.size() > 0)
      {
        WorkflowFileinbox box = (WorkflowFileinbox)fileinboxList.get(0);
        mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=finishSuccess&id=" + box.getId() + "&endFlow=1&isSuccess=1");
      }
      return mav;
    }
    if (fileinbox.getWorkflowFile().getFlowFlag().intValue() == 5)
    {
      saveNullifyMessage(fileinbox.getWorkflowFile(), request);
      mav.setViewName(this.successView);
      return mav;
    }
    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(id))) {
      createPermException(request, "协同审批->待办公文->结束", null);
    }
    Integer curStepId = fileinbox.getWorkflowStep().getId();
    
    Map filter = new HashMap();
    filter.put("flowId_i_eq", fileinbox.getWorkflow().getId());
    filter.put("steptypeId_i_eq", Integer.valueOf(8));
    List<WorkflowStep> stepList = this.workflowStepManager.findWorkflowStep(filter);
    if (stepList.size() > 0)
    {
      WorkflowStep workflowStep = (WorkflowStep)stepList.get(0);
      Map map = new HashMap();
      map.put("fileId", fileId);
      map.put("stepId", workflowStep.getId());
      map.put("curStepId", curStepId);
      map.put("userSession", userSession);
      map.put("flowId", fileinbox.getWorkflow().getId());
      
      this.workflowFileinboxManager.saveEndFlow(map, endDesc);
      

      WorkflowFile workflowFile = this.workflowFileManager.getWorkflowFile(fileId);
      
      this.workflowFileinboxManager.archive((WorkflowFileinbox)workflowFile.getWorkflowFileinboxes().iterator().next());
      

      saveMessage(request, this.workflowFileinboxManager.getMessage());
      
      Map filterFileinbox = new HashMap();
      filterFileinbox.put("workflowXXid_i_eq", fileinbox.getWorkflow().getId());
      filterFileinbox.put("workflowFileXXid_i_eq", fileId);
      filterFileinbox.put("workflowStepXXsteptypeId_i_eq", Integer.valueOf(8));
      

      List<WorkflowFileinbox> fileinboxList = this.workflowFileinboxManager.findWorkflowFileinbox(filterFileinbox);
      if (fileinboxList.size() > 0)
      {
        WorkflowFileinbox box = (WorkflowFileinbox)fileinboxList.get(0);
        mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=finishSuccess&id=" + box.getId() + "&isSuccess=1");
      }
      return mav;
    }
    return null;
  }
  
  public ModelAndView removeFileAttach(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer inboxId = new Integer(request.getParameter("inboxId"));
    WorkflowFileinbox workflowFileinbox = null;
    
    UserSession userSession = getUserSession(request);
    if (!this.workflowFileinboxManager.getHavePermOfInbox(userSession, String.valueOf(inboxId))) {
      createPermException(request, "协同审批->待办公文附件->删除", null);
    }
    try
    {
      workflowFileinbox = 
        this.workflowFileinboxManager.getWorkflowFileinbox(inboxId);
    }
    catch (Exception e)
    {
      this.logger.error(e);
    }
    if (workflowFileinbox == null)
    {
      ModelAndView mav = new ModelAndView(
        "/modules/workflow/workflowFileinbox_finish.jsp");
      mav.addObject("isSuccess", Integer.valueOf(1));
      saveMessage(request, 
      
        getMessage(request, "WorkflowFileinboxManagerController_label43", "此节点文件可能已经被取回或者被删除！"));
      return mav;
    }
    ModelAndView mav = new ModelAndView("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + String.valueOf(inboxId));
    Integer id = new Integer(request.getParameter("id"));
    this.workflowFileattachManager.removeWorkflowFileattachVer(id);
    saveMessage(request, 
      getMessage(request, "workflowFileinbox_edit_label90", "删除附件成功！"));
    return mav;
  }
  
  public ModelAndView saveFileInbox(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer flowId = new Integer(request.getParameter("flowId"));
    UserSession userSession = (UserSession)request.getSession()
      .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
    User user = this.userManager.getUser(userSession.getId());
    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager.init(
      flowId, userSession);
    String returnView = "/modules/workflow/workflowFileinbox_edit_mulit.jsp?method=create&flowId=" + 
      String.valueOf(flowId);
    BindingResult result = bindObject(request, 
      workflowFileinbox.getWorkflowFile());
    if (result.hasErrors())
    {
      ModelAndView mav = new ModelAndView("/modules/workflow/workflowFileinbox_edit_mulit.jsp");
      onBindError(request, result, mav, returnView);
      return mav;
    }
    if (workflowFileinbox.getIssent().intValue() == 9)
    {
      String deptId = request.getParameter("deptId");
      if ((deptId != null) && (!"".equals(deptId))) {
        workflowFileinbox.getWorkflowFile().setDept(
          this.deptManager.getDept(new Integer(deptId)));
      }
    }
    Map listMap = WebUtils.getParametersStartingWith(request, "listZZ");
    
    Map detailMap = 
      WebUtils.getParametersStartingWith(request, "detailstr");
    
    Map singleopinionMap = WebUtils.getParametersStartingWith(request, 
      "singleopinion_");
    
    Set keys = singleopinionMap.keySet();
    for (Object key : keys)
    {
      String myKey = (String)key;
      String value = String.valueOf(singleopinionMap.get(myKey));
      if ("1".equals(value))
      {
        String opinionStr = request.getParameter(myKey);
        if (opinionStr == null) {
          opinionStr = "";
        }
        this.workflowFileinboxManager.saveSingleOpinion(workflowFileinbox, 
          opinionStr, myKey.replace("str", ""));
      }
    }
    this.workflowFileinboxManager.convertWorkflowFilex(
      workflowFileinbox.getWorkflowFile(), listMap, detailMap);
    if ((workflowFileinbox.getWorkflowFile().getTitle() == null) || 
      ("".equals(workflowFileinbox.getWorkflowFile().getTitle()))) {
      workflowFileinbox.getWorkflowFile().setTitle(
        workflowFileinbox.getWorkflowFile().getWorkflowFlowtype()
        .getName());
    }
    this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox, true);
    if ("scanSave".equals(request.getParameter("method")))
    {
      String documentDir = "/workflow/document";
      
      String filetype = request.getParameter("filetype");
      
      String filename = request.getParameter("filename");
      if ((filename == null) || ("".equals(filename))) {
        filename = getMessage(request, 
          "WorkflowFileinboxManagerController_label27", "扫描文件");
      }
      String tempname = "scan_temp_" + userSession.getId() + "." + 
        filetype;
      
      String srcfile = "/workflow/temporary/" + 
        tempname;
      
      documentDir = documentDir + 
        "/" + 
        DateUtil.getYearmonth(workflowFileinbox.getWorkflowFile()
        .getSubmitdate()) + 
        "/" + 
        String.valueOf(workflowFileinbox.getWorkflow().getId()) + 
        "/" + 
        String.valueOf(workflowFileinbox.getWorkflowFile()
        .getId());
      String desfile = documentDir + "/" + DateUtil.getOnlyID();
      if (StorageUtil.exists(srcfile))
      {
        StorageUtil.copy(srcfile, desfile);
        WorkflowFileattach workflowFileattach = new WorkflowFileattach();
        workflowFileattach.setWorkflowFile(
          workflowFileinbox.getWorkflowFile());
        workflowFileattach.setFilename("V1_" + filename + "." + 
          filetype);
        workflowFileattach.setServerfile(desfile);
        workflowFileattach.setDescn(
          getMessage(request, "WorkflowFileinboxManagerController_label27", "扫描文件"));
        workflowFileattach.setCheckout(Integer.valueOf(0));
        workflowFileattach.setCreatedate(DateUtil.getDate());
        if ("pdf".equals(filetype)) {
          workflowFileattach.setFileext("application/pdf");
        } else {
          workflowFileattach.setFileext("image/tiff");
        }
        workflowFileattach.setFilesize(Integer.valueOf(Integer.parseInt(
          String.valueOf(StorageUtil.getSize(desfile)))));
        workflowFileattach.setLastver(Integer.valueOf(1));
        workflowFileattach.setTitle(filename);
        
        workflowFileattach.setType(Integer.valueOf(1));
        workflowFileattach.setUserByUserId(workflowFileinbox.getUser());
        workflowFileattach.setVer(Integer.valueOf(1));
        this.workflowFileattachManager.saveWorkflowFileattach(
          workflowFileattach, true);
        
        StorageUtil.delete(srcfile);
      }
    }
    String bxft = ServletRequestUtils.getStringParameter(request, "SHOW_BAOXIAOFENTAN", "no");
    if (bxft.equals("yes")) {
      if (",报销分摊开始,经营管理部审核,退回申请人,".indexOf(workflowFileinbox.getWorkflowStep().getName()) > -1)
      {
        WorkflowFile workflowFile = workflowFileinbox.getWorkflowFile();
        Map<String, String> filter = new HashMap();
        filter.put("flowtypeId_i_eq", 
          workflowFileinbox.getWorkflow().getFlowtypeId().toString());
        List<WorkflowFlowfield> fields = this.workflowFlowfieldManager
          .findWorkflowFlowfield(filter);
        






















        String bxdateName = "";
        String bxlxName = "";
        String bxnrzyName = "";
        String jeName = "";
        String bzName = "";
        String hjName = "";
        String pzCountName = "";
        for (WorkflowFlowfield field : fields) {
          if ("报销类型".equals(field.getName()))
          {
            bxlxName = "fieldstr" + field.getFieldserial();
          }
          else
          {
            if (",报销内容摘要,金额,备注,".contains("," + field.getName() + 
              ",")) {
              if (field.getFieldtype().equals("list"))
              {
                String fname = "fieldstr" + field.getFieldserial() + "ZZ";
                if ("报销内容摘要".equals(field.getName()))
                {
                  bxnrzyName = fname; continue;
                }
                if ("金额".equals(field.getName()))
                {
                  jeName = fname; continue;
                }
                bzName = fname; continue;
              }
            }
            if ("合计金额".equals(field.getName())) {
              hjName = "fieldstr" + field.getFieldserial();
            } else if ("报销日期".equals(field.getName())) {
              bxdateName = "fieldstr" + field.getFieldserial();
            } else if ("凭证张数".equals(field.getName())) {
              pzCountName = "fieldstr" + field.getFieldserial();
            }
          }
        }
        PlBaoxiao plBaoxiao = null;
        plBaoxiao = new PlBaoxiao();
        plBaoxiao.setWorkflowFile(workflowFile);
        plBaoxiao.setCreatedate(workflowFile.getSubmitdate());
        plBaoxiao.setDept(workflowFile.getDept());
        plBaoxiao.setUser(workflowFile.getUser());
        plBaoxiao.setBxdNo(workflowFile.getFileno());
        Object value = ReflectUtil.getClassAttributeValue(workflowFile, 
          bxdateName);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        
        plBaoxiao.setBsdate(sdf.parse((String)value));
        
        value = ReflectUtil.getClassAttributeValue(workflowFile, 
          pzCountName);
        plBaoxiao.setPzCount(
          Integer.valueOf(String.valueOf((String)value)));
        
        int bxtype_id = ServletRequestUtils.getIntParameter(request, "bxtype", 0);
        PlDicts bxtype = this.plDictsManager.getPlDicts(Integer.valueOf(bxtype_id));
        plBaoxiao.setPlDicts(bxtype);
        
        value = ReflectUtil.getClassAttributeValue(workflowFile, hjName);
        plBaoxiao.setHejiSum(Double.valueOf(Double.parseDouble(value.toString())));
        
        this.plBaoxiaoManager.savePlBaoxiao(plBaoxiao);
        






















        this.jdbcTemplate.execute("delete from pl_baoxiao_mx where bx_id=" + 
          plBaoxiao.getId());
        for (int i = 1; i <= 4; i++)
        {
          String jeStr = (String)listMap.get(jeName + i);
          if (!jeStr.equals(""))
          {
            PlBaoxiaoMx plBaoxiaoMx = new PlBaoxiaoMx();
            plBaoxiaoMx.setBxSum(Double.valueOf(jeStr));
            plBaoxiaoMx
              .setContent((String)listMap.get(bxnrzyName + i));
            plBaoxiaoMx.setRemark((String)listMap.get(bzName + i));
            plBaoxiaoMx.setPlBaoxiao(plBaoxiao);
            this.plBaoxiaoMxManager.savePlBaoxiaoMx(plBaoxiaoMx);
          }
        }
        String isfentan = ServletRequestUtils.getStringParameter(request, "isfentan", "no");
        if (isfentan.equals("yes"))
        {
          PlFentanBase plFentanBase = null;
          plFentanBase = new PlFentanBase();
          plFentanBase.setPlBaoxiao(plBaoxiao);
          plFentanBase.setUser(user);
          String ftNo = ServletRequestUtils.getStringParameter(request, "ftNo", "");
          plFentanBase.setFtNo(ftNo);
          plFentanBase.setCreatedate(new Date());
          plFentanBase.setFtSum(Double.valueOf(ServletRequestUtils.getDoubleParameter(request, "ftSum", 0.0D)));
          this.plFentanBaseManager.savePlFentanBase(plFentanBase);
          
          Map<String, String> fentanFilter = new HashMap();
          fentanFilter.put("plFentanBaseXXid_i_eq", 
            plFentanBase.getId().toString());
          List<PlFentan> plFentans = this.plFentanManager
            .findPlFentan(fentanFilter);
          for (PlFentan plFentan : plFentans) {
            this.plFentanManager.removePlFentan(plFentan.getId());
          }
          int[] indexs = ServletRequestUtils.getIntParameters(request, "currIndex");
          int kumuid;
          int deptid;
          String begin;
          if (indexs != null)
          {
            sdf.applyPattern("yyyy-MM");
            for (int i = 0; i < indexs.length; i++)
            {
              int plFentan_id = ServletRequestUtils.getIntParameter(request, 
                "plFentan_id_" + indexs[i], -1);
              kumuid = ServletRequestUtils.getIntParameter(request, "kemu_id_" + 
                indexs[i], -1);
              deptid = ServletRequestUtils.getIntParameter(request, "dept_id_" + 
                indexs[i], -1);
              begin = ServletRequestUtils.getStringParameter(request, "beginDate_" + 
                indexs[i], "");
              String end = ServletRequestUtils.getStringParameter(request, "endDate_" + 
                indexs[i], "");
              double ftSum = ServletRequestUtils.getDoubleParameter(request, "ftSum_" + 
                indexs[i], -1.0D);
              int fkfs = ServletRequestUtils.getIntParameter(request, 
                "fkfs_" + indexs[i], -1);
              String remark = ServletRequestUtils.getStringParameter(request, "remark_" + 
                indexs[i], "");
              
              PlKemu plKemu = this.plKemuManager.getPlKemu(Integer.valueOf(kumuid));
              Dept dept = this.deptManager.getDept(Integer.valueOf(deptid));
              PlDicts plDicts = this.plDictsManager.getPlDicts(Integer.valueOf(fkfs));
              
              PlFentan ft = new PlFentan();
              ft.setCreatedate(new Date());
              ft.setPlFentanBase(plFentanBase);
              ft.setUser(user);
              
              Date beginDate = sdf.parse(begin);
              Date endDate = sdf.parse(end);
              ft.setBeginDate(beginDate);
              ft.setEndDate(endDate);
              
              ft.setDept(dept);
              ft.setFtSum(Double.valueOf(ftSum));
              ft.setKm(plKemu);
              ft.setPlDictsByFkfs(plDicts);
              ft.setRemark(remark);
              
              this.plFentanManager.savePlFentan(ft);
              
              Calendar calendar = Calendar.getInstance();
              calendar.setTime(beginDate);
              Calendar endCalendar = Calendar.getInstance();
              endCalendar.setTime(endDate);
              int n = 0;
              for (; !calendar.after(endCalendar); n++) {
                calendar.set(2, 
                  calendar.get(2) + 1);
              }
              calendar.setTime(beginDate);
              for (int j = 0; j < n; j++)
              {
                PlFentanMx mx = new PlFentanMx();
                mx.setPlFentan(ft);
                mx.setFtDate(sdf.format(calendar.getTime()));
                calendar.set(2, 
                  calendar.get(2) + 1);
                mx.setFtSum(Double.valueOf(ftSum / n));
                
                this.plFentanMxManager.savePlFentanMx(mx);
              }
            }
          }
          int[] hzids = ServletRequestUtils.getIntParameters(request, "hzid");
          if (hzids != null) {
            for (int hzid : hzids)
            {
              PlHuizong plHuizong = this.plHuizongManager
                .getPlHuizong(Integer.valueOf(hzid));
              plHuizong.setStatus(Integer.valueOf(1));
              plHuizong.setFlowfileId(workflowFile.getId());
              this.plHuizongManager.savePlHuizong(plHuizong);
            }
          }
        }
      }
    }
    String type = request.getParameter("type");
    String textType = request.getParameter("textType");
    ModelAndView mav = new ModelAndView(
      "/modules/workflow/workflowFileattach.do?method=online&inboxId=" + 
      workflowFileinbox.getId() + "&fileId=" + 
      workflowFileinbox.getWorkflowFile().getId() + 
      "&type=" + type + "&textType=" + textType + 
      "&flowId=" + flowId);
    if (this.workflowFileManager.findWorkflowNo(
      workflowFileinbox.getWorkflowFile()))
    {
      saveMessage(request, 
        getMessage(request, "WorkflowFileinboxManagerController_label31", "文件编号'") + 
        workflowFileinbox.getWorkflowFile().getFileno() + 
        "已重复,请重新输入文件编号!");
      mav
        .setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
        workflowFileinbox.getId());
    }
    return mav;
  }
  
  private void onlineCreateFile(HttpServletRequest request, HttpServletResponse response, WorkflowFileinbox workflowFileinbox, ModelAndView mav)
    throws Exception
  {
    UserSession user = getUserSession(request);
    String title = request.getParameter("fileTitle");
    if ((title == null) || ("".equals(title)))
    {
      title = workflowFileinbox.getWorkflowFile().getTitle();
      if (title.length() > 20) {
        title = title.substring(0, 19);
      }
      title = title.replaceAll("[#$%\\\\/:*?\"<>|\\s]", "-");
    }
    Map map = new HashMap();
    map.put("workflowFileXXid_i_eq", String.valueOf(
      workflowFileinbox.getWorkflowFile().getId()));
    map.put("lastver_i_eq", "1");
    map.put("userByUserIdXXid_i_eq", String.valueOf(user.getId()));
    map.put("title_s_eq", title);
    if ((request.getParameter("textType") != null) && ("excel".equals(request.getParameter("textType")))) {
      map.put("fileext_s_eq", "application/vnd.ms-excel");
    } else {
      map.put("fileext_s_eq", "application/msword");
    }
    WorkflowFileattach workflowFileattach = null;
    List workflowFileattachList = this.workflowFileattachManager
      .findWorkflowFileattach(map);
    if (workflowFileattachList.size() > 0)
    {
      workflowFileattach = 
        (WorkflowFileattach)workflowFileattachList.get(0);
    }
    else
    {
      workflowFileattach = new WorkflowFileattach();
      workflowFileattach.setTitle(title);
      workflowFileattach.setType(Integer.valueOf(1));
      workflowFileattach.setDescn("");
      
      workflowFileattach.setCheckout(Integer.valueOf(0));
      workflowFileattach.setCreatedate(DateUtil.getDate());
      workflowFileattach.setVer(Integer.valueOf(1));
      workflowFileattach.setLastver(Integer.valueOf(1));
      workflowFileattach.setWorkflowFile(
        workflowFileinbox.getWorkflowFile());
      workflowFileattach.setUserByUserId(workflowFileinbox.getUser());
      
      this.documentDir = 
      





        ("/workflow/document" + File.separator + DateUtil.getYearmonth(workflowFileinbox.getWorkflowFile().getSubmitdate()) + File.separator + String.valueOf(workflowFileinbox.getWorkflow().getId()) + File.separator + String.valueOf(workflowFileinbox.getWorkflowFile()
        .getId()));
      
      String filename = "V" + String.valueOf(workflowFileattach.getVer()) + 
        "_" + title + ".doc";
      



















      String documentDirFile = this.documentDir + File.separator + 
        DateUtil.getOnlyID();
      
      String templatefile = "/workflow/template" + File.separator + 
        workflowFileinbox.getWorkflow().getFlowtypeId() + 
        File.separator + "formal.doc";
      



















      String fileext = "application/msword";
      if ((workflowFileattach.getWorkflowFile().getWorkflow().getEditStyle().intValue() == 1) && 
        (workflowFileattach.getWorkflowFile().getWorkflow().getTextType() != null) && 
        (workflowFileattach.getWorkflowFile().getWorkflow().getTextType().intValue() == 1))
      {
        filename = 
          "V" + String.valueOf(workflowFileattach.getVer()) + "_" + title + ".xls";
        templatefile = "/workflow/template" + File.separator + 
          "blank.xls";
        fileext = "application/vnd.ms-excel";
      }
      if ((request.getParameter("textType") != null) && ("excel".equals(request.getParameter("textType"))))
      {
        filename = 
          "V" + String.valueOf(workflowFileattach.getVer()) + "_" + title + ".xls";
        templatefile = "/workflow/template" + File.separator + 
          "blank.xls";
        fileext = "application/vnd.ms-excel";
      }
      if (StorageUtil.exists(templatefile))
      {
        StorageUtil.copy(templatefile, documentDirFile);
      }
      else
      {
        templatefile = 
        
          "/workflow/template" + File.separator + workflowFileinbox.getWorkflow().getFlowtypeId() + File.separator + "blank.doc";
        StorageUtil.copy(templatefile, documentDirFile);
      }
      workflowFileattach.setFilename(filename);
      workflowFileattach.setServerfile(documentDirFile);
      workflowFileattach.setFileext(fileext);
      workflowFileattach.setFilesize(new Integer(
        String.valueOf(StorageUtil.getSize(documentDirFile))));
      this.workflowFileattachManager.saveWorkflowFileattach(
        workflowFileattach, true);
    }
    String retMav = "redirect:/modules/workflow/workflowFileattach.do?method=postil&inboxId=" + workflowFileinbox.getId() + 
      "&topicId=" + workflowFileattach.getTopicId() + "&isEditFile=yes";
    mav.setViewName(retMav);
  }
  
  public ModelAndView loadNTKOWebSign(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String fileId = request.getParameter("fileId");
    String stepId = request.getParameter("stepId");
    if (StringUtils.isBlank(fileId)) {
      return null;
    }
    Map filter = new HashMap();
    filter.put("fileId_i_eq", fileId);
    filter.put("signType_i_eq", "1");
    List<WorkflowWebsign> workflowWebsigns = this.workflowWebsignManager.findWorkflowWebsign(filter);
    WorkflowWebsign workflowWebsign = null;
    if ((workflowWebsigns != null) && (workflowWebsigns.size() > 0)) {
      workflowWebsign = (WorkflowWebsign)workflowWebsigns.get(0);
    } else {
      return null;
    }
    InputStream ins = null;
    OutputStream sos = null;
    try
    {
      String serverfile = workflowWebsign.getServerfile();
      serverfile = org.springside.core.Constants.MAIN_STORAGE_DIR + serverfile;
      File file = new File(serverfile);
      if (file.exists())
      {
        response.setContentType("application/octet-stream");
        response.setContentLength(new Integer(String.valueOf(file.length())).intValue());
        response.setHeader("Content-Disposition", "attachment; filename=" + 
          new String(file.getName().getBytes("GBK"), "ISO-8859-1") + ".esp");
        ins = new FileInputStream(serverfile);
        sos = response.getOutputStream();
        byte[] fileData = new byte[1024];
        int readCount = 0;
        while ((readCount = ins.read(fileData, 0, 1024)) != -1) {
          sos.write(fileData, 0, readCount);
        }
        sos.flush();
        response.flushBuffer();
      }
    }
    catch (IOException e)
    {
      e.printStackTrace();
      try
      {
        if (ins != null) {
          ins.close();
        }
        if (sos != null) {
          sos.close();
        }
      }
      catch (IOException localIOException1) {}
    }
    finally
    {
      try
      {
        if (ins != null) {
          ins.close();
        }
        if (sos != null) {
          sos.close();
        }
      }
      catch (IOException localIOException2) {}
    }
    return null;
  }
  
  public ModelAndView ajaxCheckWebSignExists(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    String fileId = request.getParameter("fileId");
    String stepId = request.getParameter("stepId");
    if (StringUtils.isBlank(fileId)) {
      return null;
    }
    Map filter = new HashMap();
    filter.put("fileId_i_eq", fileId);
    filter.put("signType_i_eq", "1");
    List<WorkflowWebsign> workflowWebsigns = this.workflowWebsignManager.findWorkflowWebsign(filter);
    response.setCharacterEncoding("UTF-8");
    if ((workflowWebsigns != null) && (workflowWebsigns.size() > 0))
    {
      response.getWriter().write("yes");
      return null;
    }
    response.getWriter().write("no");
    return null;
  }
  
  public ModelAndView officeAdd(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    ModelAndView mav = new ModelAndView();
    
    UserSession user = getUserSession(request);
    
    String strType = request.getParameter("ec_cu");
    Integer type = Integer.valueOf("1".equals(strType) ? 0 : 1);
    
    Integer flowId = Integer.valueOf(0);
    try
    {
      flowId = new Integer(request.getParameter("flowId"));
    }
    catch (NumberFormatException ex)
    {
      mav.setViewName(this.listView);
      return mav;
    }
    WorkflowFileinbox workflowFileinbox = null;
    try
    {
      workflowFileinbox = this.workflowFileinboxManager.init(flowId, user);
    }
    catch (Exception e)
    {
      mav.setViewName(this.listView);
      return mav;
    }
    WorkflowStep workflowStep = workflowFileinbox.getWorkflowStep();
    WorkflowFile workflowFile = workflowFileinbox.getWorkflowFile();
    Workflow workflow = workflowFileinbox.getWorkflow();
    
    workflowFile.setTitle("无标题");
    String name;
    if ("报销分摊开始".equals(workflowStep.getName()))
    {
      Map<String, String> filter = new HashMap();
      filter.put("flowtypeId_i_eq", workflow.getFlowtypeId().toString());
      List<WorkflowFlowfield> fields = this.workflowFlowfieldManager.findWorkflowFlowfield(filter);
      












      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
      for (WorkflowFlowfield field : fields)
      {
        name = field.getName();
        Integer serial = field.getFieldserial();
        if ("报销日期".equals(name)) {
          ReflectUtil.setClassAttributeValue(workflowFile, "fieldstr" + serial, sdf.format(new Date()));
        }
      }
    }
    WorkflowFlowtype workflowFlowtype = workflowFile.getWorkflowFlowtype();
    if (Integer.valueOf(1).equals(workflowFlowtype.getFilenoAuto())) {
      try
      {
        WorkflowFileno workflowFileno = this.workflowFileinboxManager.saveFileno(workflowFileinbox);
        if ((workflowFileno != null) && (!StringUtils.isBlank(workflowFileno.getFilenoLast())))
        {
          String[] fileno = workflowFileno.getFilenoLast().split("@");
          if (fileno.length == 3) {
            workflowFile.setFileno(fileno[0].trim() + fileno[1].trim() + fileno[2].trim());
          }
        }
      }
      catch (BusinessException e)
      {
        this.logger.error(e);
      }
    }
    if (Integer.valueOf(1).equals(workflow.getIsIntegration()))
    {
      String errorMsg = this.workflowIntegrationManager.getIntegrationData(workflowFile, workflowStep);
      if (StringUtils.isNotEmpty(errorMsg)) {
        saveMessage(request, errorMsg);
      }
    }
    this.workflowFileinboxManager.handleSystemDate(workflowFileinbox);
    this.workflowFileinboxManager.handleSystemTime(workflowFileinbox);
    
    this.workflowFileinboxManager.saveWorkflowFileinbox(workflowFileinbox, true);
    












    String ec_token = request.getParameter("ec_token");
    ServletContext ctx = getServletContext();
    List<Map<String, String>> list = Upload.get(ctx, ec_token);
    for (Object attach : list)
    {
      WorkflowFileattach workflowFileattach = new WorkflowFileattach();
      
      workflowFileattach.setCheckout(Integer.valueOf(0));
      workflowFileattach.setCreatedate(DateUtil.getDate());
      workflowFileattach.setVer(Integer.valueOf(1));
      workflowFileattach.setLastver(Integer.valueOf(1));
      workflowFileattach.setWorkflowFile(workflowFile);
      workflowFileattach.setUserByUserId(workflowFileinbox.getUser());
      
      String documentDir = "/workflow/document/" + 
        DateUtil.getYearmonth(workflowFile.getSubmitdate()) + 
        "/" + String.valueOf(workflow.getId()) + 
        "/" + String.valueOf(workflowFile.getId());
      
      String fileTitle = (String)((Map)attach).get("name");
      workflowFileattach.setTitle(fileTitle);
      workflowFileattach.setType(type);
      
      String serverfile = documentDir + "/" + DateUtil.getOnlyID();
      StorageUtil.copy((String)((Map)attach).get("filepath"), serverfile);
      workflowFileattach.setServerfile(serverfile);
      workflowFileattach.setFilename("V1_" + fileTitle);
      workflowFileattach.setFileext((String)((Map)attach).get("ext"));
      String extension = (String)((Map)attach).get("extension");
      if (("doc".equals(extension)) || ("docx".equals(extension))) {
        workflowFileattach.setFileext("application/msword");
      }
      if (("xls".equals(extension)) || ("xlsx".equals(extension))) {
        workflowFileattach.setFileext("application/vnd.ms-excel");
      }
      Long filesize = Long.valueOf(Long.parseLong((String)((Map)attach).get("size")));
      workflowFileattach.setFilesize(new Integer(String.valueOf(filesize)));
      this.workflowFileattachManager.saveWorkflowFileattach(workflowFileattach, true);
    }
    mav.setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + workflowFileinbox.getId());
    
    return mav;
  }
  
  public ModelAndView ajaxCheckTreeDic(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    int id = ServletRequestUtils.getIntParameter(request, "id", 0);
    
    SystemDictionary systemDictionary = this.systemDictionaryManager.getSystemDictionary(Integer.valueOf(id));
    if ((systemDictionary != null) && (systemDictionary.getLongCodes() != null))
    {
      String[] longcodes = systemDictionary.getLongCodes().split("!");
      
      SystemDictionary systemDictionaryRoot = this.systemDictionaryManager.getSystemDictionary(Integer.valueOf(longcodes[0]));
      if (systemDictionaryRoot != null) {
        if ("0".equals(systemDictionaryRoot.getSelectable()))
        {
          Map filter = new HashMap();
          filter.put("longCodes_s_likeleft", systemDictionary.getLongCodes());
          filter.put("id_i_ne", String.valueOf(id));
          List list = this.systemDictionaryManager.findSystemDictionary(filter);
          if (list.size() > 0) {
            response.getWriter().write("false");
          } else {
            response.getWriter().write("true");
          }
        }
        else
        {
          response.getWriter().write("true");
        }
      }
    }
    return null;
  }
  
  public void ajaxWorkflowFlowfieldHtml(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Writer writer = response.getWriter();
    try
    {
      String workflowId = request.getParameter("workflowId");
      Workflow workflow = this.workflowManager.getWorkflow(Integer.valueOf(workflowId));
      String html = this.workflowFlowfieldManager.getWorkflowFlowfieldHtml(workflow.getFlowtypeId(), getUserSession(request));
      
      response.setContentType("text/plain;charset=UTF-8");
      response.setHeader("Cache-Control", "no-store");
      response.setHeader("Pragma", "no-cache");
      response.setDateHeader("Expires", 0L);
      writer.write(html);
    }
    catch (Exception e)
    {
      this.logger.error("ajaxWorkflowFlowfieldHtml Failed!!", e);
    }
    finally
    {
      if (writer != null) {
        writer.close();
      }
    }
  }
  
  public void setWorkflowKnowledgeManager(WorkflowKnowledgeManager workflowKnowledgeManager)
  {
    this.workflowKnowledgeManager = workflowKnowledgeManager;
  }
  
  public void setWorkflowSearchManager(WorkflowSearchManager workflowSearchManager)
  {
    this.workflowSearchManager = workflowSearchManager;
  }
  
  public void setWorkflowSearchFieldManager(WorkflowSearchFieldManager workflowSearchFieldManager)
  {
    this.workflowSearchFieldManager = workflowSearchFieldManager;
  }
  
  public ModelAndView ajaxDictTree(HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    Integer dictId = Integer.valueOf(ServletRequestUtils.getIntParameter(request, "dictId", 0));
    Integer parentId = Integer.valueOf(ServletRequestUtils.getIntParameter(request, "parentId", dictId.intValue()));
    Integer pid = Integer.valueOf(ServletRequestUtils.getIntParameter(request, "id", 0));
    
    String json = this.systemDictionaryManager.getDictTreeJson(dictId, pid, false);
    response.setContentType("text/plain;charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    Writer writer = response.getWriter();
    writer.write(json);
    writer.close();
    return null;
  }
  
  
  //==================================2015-01-20升级处理==================================
  
  //2014-01-03 二开新增 办结变更处理
 public void setWorkflowFileChangeManager(WorkflowFileChangeManager workflowFileChangeManager) {
		this.workflowFileChangeManager = workflowFileChangeManager;
  }
 private WorkflowFileChangeManager workflowFileChangeManager;
 
 //=====================================================================
 //2014-01-03 新增办结工作流变更处理
 /**
  * 文件变更处理
  * @param request
  * @param response
  * @param mav
  * @return
  * @throws Exception
  */
 public ModelAndView applychange(HttpServletRequest request, HttpServletResponse response, ModelAndView mav)
		    throws Exception
		  {
		    UserSession userLogin = (UserSession)request.getSession()
		      .getAttribute(org.springside.core.Constants.USER_IN_SESSION);
		    Integer id = new Integer(request.getParameter("id"));
		    String applyuserid = request.getParameter("applychangeUser");//applyUser   applychangeUser
		    String remark=request.getParameter("remark");
		    WorkflowFileinbox workflowFileinbox = this.workflowFileinboxManager
		      .getWorkflowFileinbox(id);
		    WorkflowFileChange workflowFileChange = null;

		    if ((request.getParameter("pid") != null) && 
		      (!"".equals(request.getParameter("pid")))) {
		      Integer pid = Integer.valueOf(Integer.parseInt(request.getParameter("pid")));
		      workflowFileChange = this.workflowFileChangeManager.getWorkflowFileChange(pid);
		      if (workflowFileChange.getStatus().intValue() == 5) {
		    	  workflowFileChange = new WorkflowFileChange();
		    	  workflowFileChange.setApplyUser(this.userManager.getUser(userLogin.getId()));
		    	  workflowFileChange.setWorkflowFileinbox(workflowFileinbox);
		    	  workflowFileChange.setRemark(remark);
		    	  workflowFileChange.setSolveUser(this.userManager
		          .getUser(Integer.valueOf(Integer.parseInt(applyuserid))));
		    	  workflowFileChange.setApplyTime(DateUtil.getDate());
		    	  workflowFileChange.setStatus(Integer.valueOf(2));
		      } else {
		    	  workflowFileChange.setStatus(Integer.valueOf(2));
		    	  workflowFileChange.setApplyTime(DateUtil.getDate());
		    	  workflowFileChange.setRemark(remark);
		    	  workflowFileChange.setSolveUser(this.userManager
		          .getUser(Integer.valueOf(Integer.parseInt(applyuserid))));
		      }
		    } else {
		    	workflowFileChange = new WorkflowFileChange();
		    	workflowFileChange.setApplyUser(this.userManager.getUser(userLogin.getId()));
		    	workflowFileChange.setWorkflowFileinbox(workflowFileinbox);
		    	workflowFileChange.setRemark(remark);
		    	workflowFileChange.setSolveUser(this.userManager
		        .getUser(Integer.valueOf(Integer.parseInt(applyuserid))));
		    	workflowFileChange.setApplyTime(DateUtil.getDate());
		    	workflowFileChange.setStatus(Integer.valueOf(2));
		    }

		    this.workflowFileChangeManager.saveWorkflowFileChange(workflowFileChange);
		    Messages messages = new Messages();
		    messages.setTitle(
		    		workflowFileChange.getWorkflowFileinbox().getWorkflowFile().getTitle() + 
		      "文件有办结文件变更申请,来自[公文处理]");
		    messages.setCreatedate(DateUtil.getDate());
		    String content = workflowFileChange.getApplyUser().getName() + "对工作流文件[" + 
		    		workflowFileChange.getWorkflowFileinbox().getWorkflowFile().getTitle() + 
		      "]申请办结文件变更，请处理！";
		    messages.setContent(content);
		    messages.setFromId(Integer.valueOf(0));
		    messages.setIsread(Integer.valueOf(0));
		    messages.setSourceId(Integer.valueOf(3));
		    messages.setType(Integer.valueOf(1));
		    messages.setPri(Integer.valueOf(2));
		    messages.setUserByUserId(workflowFileChange.getSolveUser());
		    messages.setUserByFromuserId(workflowFileChange.getApplyUser());
		    messages.setAttachs("");
		    messages
		      .setUrl("../../modules/workflow/workflowFileChange.do?method=list");
		    messages.setEntityId(workflowFileChange.getId());
		    messages.setEntityClass(workflowFileChange.getClass().getName());
		    this.messagesManager.saveMessages(messages, 0);
		    if (request.getParameter("type").equals("edit"))
		      mav
		        .setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=edit&id=" + 
		        id);
		    else {
		      mav
		        .setViewName("redirect:/modules/workflow/workflowFileinbox.do?method=show&id=" + 
		        id);
		    }

		    return mav;
		  }

 
			/**
			* 2014-01-11支持扩展的二层表打印功能
			* fjfdszj
			* @param request
			* @param response
			* @return
			* @throws Exception
			*/
			public ModelAndView goToPrintEx(HttpServletRequest request, HttpServletResponse response)
			throws Exception
			{
				ModelAndView mav = new ModelAndView(
				 "/modules/workflow/workflowFileattach_wordprintex2.jsp");
				Integer id = new Integer(request.getParameter("fileinboxId"));
				String tablename = request.getParameter("tablename").toString();
				
				List<WorkflowFlowfield> list = this.workflowFileChangeManager.K3TableColumndata(tablename);
				
				mav.addObject("workflowFlowfields", list);
				return mav;
			}


 //======================================
}
